by Devin Yang
(This article was automatically translated.)

Published - 7 years ago ( Updated - 7 years ago )

Sort from largest to smallest
alias duf='du -sk * | sort -r -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\'
In the above command, sort -r will sort from large to small, if we want to sort from small to large, we can remove -r .
We only need to paste it to the terminal of Linux or Mac , and then we can enter duf to list the size of the folder or file.
If you want to make this duf command permanent, add it to .bashrc or .bash_profile . (I believe you understand)
$duf
16.2G sites
208.8M data
48.0K etc
20.0K scripts
20.0K samples
16.0K README.md
12.0K console
8.0K create
4.0K docker-compose.yml
4.0K docker-compose-random.yml
4.0K docker-compose-normal.yml
4.0K docker-compose-custom.yml
4.0K dlaravel
4.0K LICENSE
0.0K run

Tags: sort

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments