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

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

    If you need to get total size, here is a script proposal

    #!/bin/bash
    totalSize=0
    
    allSizes=`find . -type f -name *.ear -exec stat -c "%s" {} \;`
    
    for fileSize in $allSizes; do
        totalSize=`echo "$(($totalSize+$fileSize))"`
    done
    echo "Total size is $totalSize bytes"
    

提交回复
热议问题