Oneliner To Display Filesize With Line And Word Count
2/23/2013 10:33:00 AM
Jsc Jwhat Jerome Christopher
, Posted in
Computers
,
Linux
,
Live cd
,
Puppy Linux
,
Tips'nTricks
It looks logical but have you ever thought of the file size as the total number of characters in a file?
I didn't, for a very long time!
This command returns the size of all files in a directory with line, word and character counts also! As we said just above, the character count happens to be the filesize also!
wc `ls -p|grep -v "/$"`|gawk -F " " '{print $1 "\t" $2 "\t" $3 "\t" $4|"sort -gk 1"}'
Let us break it down:
wc : Find line, word and character counts
ls -p|grep -v "/$" : List files in directory without directory information
gawk -F " " '{print $1 "\t" $2 "\t" $3 "\t" $4 : List lines, words, chars and file
names
sort -gk 1 : Sort the above on line count
Just remember that
- there should be no spaces in file names.
- there should be at least one file in the directory.
Works on Puppy Lucid510 Linux, may work on other flavors. Test it out for yourself!