Short command to find total size of files matching a wild card

前端 未结 3 2067
自闭症患者
自闭症患者 2021-02-18 14:04

I could envision a simple shell script that would accomplish what I want by just iterating through a list of files in a directory and summing the individual size but was wonderi

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-18 14:37

    You can use this function :

    dir () { ls -FaGl "${@}" | awk '{ last_size += $4; print }; END { print last_size }'; }
    

    also you can use this command this is shorter and give you better result!

    find YOUR_PATH -type f -name '*.jpg' -exec du -ch {} +
    

提交回复
热议问题