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

前端 未结 15 546
无人及你
无人及你 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:47

    Try the following commands:

    GNU stat:

    find . -type f -name *.ear -exec stat -c "%n %s" {} ';'
    

    BSD stat:

    find . -type f -name *.ear -exec stat -f "%N %z" {} ';'
    

    however stat isn't standard, so du or wc could be a better approach:

    find . -type f -name *.ear -exec sh -c 'echo "{} $(wc -c < {})"' ';'
    

提交回复
热议问题