Thursday, April 25, 2024
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 6532  / 1 Year ago, sun, february 5, 2023, 10:59:47

How can I list files having more than 100 lines in a directory and in all its sub directories? An example of such a terminal command will be very helpful.



Is there a tool to count the line numbers of given files?


More From » command-line

 Answers
1

Use the following command:



find <folder-to-search> -name "*.txt" -type f -exec sh -c 'test `wc -l {} | cut -f1 -d" "` -gt "100"' ; -print


Also take a look at the -name parameter, currently you will find only files that end with .txt. You want to alter that or, just delete the parameter and the argument to find all files.


[#31011] Monday, February 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
girdleas

Total Points: 1
Total Questions: 112
Total Answers: 114

Location: Lesotho
Member since Wed, Jun 2, 2021
3 Years ago
girdleas questions
;