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

后端 未结 11 1508
遥遥无期
遥遥无期 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 08:59

    I think I might have figured out what you want to do. This will give a sorted list of all the files and all the directories, sorted by file size and size of the content in the directories.

    (find . -depth 1 -type f -exec ls -s {} \;; find . -depth 1 -type d -exec du -s {} \;) | sort -n
    

提交回复
热议问题