Multi-Search3

Oneliner To Display Filesize With Line And Word Count




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!


BlogCollage


Blog Collage - Top Random Posts In No Particular Order

Mouseover the images for title and comments