How do I get the find command to print out the file size with the file name?

前端 未结 15 563
无人及你
无人及你 2020-12-07 11:01

If I issue the find command as follows:

$ find . -name *.ear

It prints out:

./dir1/dir2/earFile1.ear
./dir1/dir2/earFile2.         


        
15条回答
  •  死守一世寂寞
    2020-12-07 11:52

    a simple solution is to use the -ls option in find:

    find . -name \*.ear -ls
    

    That gives you each entry in the normal "ls -l" format. Or, to get the specific output you seem to be looking for, this:

    find . -name \*.ear -printf "%p\t%k KB\n"
    

    Which will give you the filename followed by the size in KB.

提交回复
热议问题