Sample Header Ad - 728x90

How to count the number of lines per file in a directory, then create summary of number of files with n lines

1 vote
2 answers
1371 views
I'm trying to create a summary of how many files in a directory have n number of lines in them. I'm using wc -l * | sort to print out the number of lines against the name of each file. What I'm trying to achieve is a summary of the directory which would produce: 56 5 60 6 3 7 etc, where the first column represents number of files and the second represents number of lines. I've looked at an awk command awk 'END{print NR}' directory/* which returns the number of lines in the entire directory. I have considered a printf solution to format the wc -l output . Any assistance would be greatly greatly appreciated! Thank you
Asked by Doodling (19 rep)
Aug 27, 2022, 06:19 AM
Last activity: Aug 27, 2022, 10:15 AM