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

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

    This should get you what you're looking for, formatting included (i.e. file name first and size afterward):

    find . -type f -iname "*.ear" -exec du -ah {} \; | awk '{print $2"\t", $1}'
    

    sample output (where I used -iname "*.php" to get some result):

    ./plugins/bat/class.bat.inc.php  20K
    ./plugins/quotas/class.quotas.inc.php    8.0K
    ./plugins/dmraid/class.dmraid.inc.php    8.0K
    ./plugins/updatenotifier/class.updatenotifier.inc.php    4.0K
    ./index.php      4.0K
    ./config.php     12K
    ./includes/mb/class.hwsensors.inc.php    8.0K
    

提交回复
热议问题