How to list the size of each file and directory and sort by descending size in Bash?

后端 未结 11 1517
遥遥无期
遥遥无期 2020-12-07 08:02

I found that there is no easy to get way the size of a directory in Bash?

I want that when I type ls -, it can list of all the sum o

11条回答
  •  余生分开走
    2020-12-07 09:05

    Simply navigate to directory and run following command:

    du -a --max-depth=1 | sort -n
    

    OR add -h for human readable sizes and -r to print bigger directories/files first.

    du -a -h --max-depth=1 | sort -hr
    

提交回复
热议问题