Hi Dude, This is short article about linux show size file and folder directory. Little tips to show size directory, and print result sort ascending base of size file.
Basicly, this is combine between command du
and sort
. Function of sort is filtering outoput from big size to tiny size.
du -sh * | sort -hr
Example like below.
root@hostname:/var/log# du -sh * | sort -hr
15M installer
2.5M syslog.1
2.1M vmware-caf
440K syslog
424K udev
296K upstart
144K kern.log.1
120K syslog.2.gz
112K syslog.6.gz
112K syslog.5.gz
108K syslog.7.gz
108K syslog.3.gz
100K dmesg.0
100K dmesg
Show Size Folder Only
And then Sort the output of the 'du'
command by largest first, with using human readable output.
du -h --max-depth=1 | sort -rh
Example like below.
root@hostname:/var/log# du -h --max-depth=1 | sort -rh
22M .
15M ./installer
2.1M ./vmware-caf
296K ./upstart
40K ./mysql
28K ./apt
12K ./fsck
4.0K ./unattended-upgrades
4.0K ./landscape
4.0K ./dist-upgrade
To see all manual about sort command, type sort -help.