Friday, November 11, 2011

Linux show total lines of files in a directory (sorted by line numbers)

Linux showing total number of lines of each file in a directory:

wc -l *

Even better, you can have the results sorted by line numbers:

wc -l * | sort -n -k1

-n         compare according to string numerical value
-k#       define start position