Find and List Files from Largest to Smallest in Linux

~ 0 min
2021-08-06 12:29

Use this command to create a descending list of files by size for a path in Linux:

find /directory/to/scan/ -type f -exec du -a {} + | sort -n -r | less

You will receive output like so:

518144 /var/lib/mysql/ibdata1
180764 /var/log/asterisk/fail2ban-20210718
126812 /var/lib/rpm/Packages
103720 /var/log/asterisk/freepbx.log-20210221
103272 /var/log/asterisk/freepbx.log-20200615
103268 /var/log/asterisk/freepbx.log-20200911
103232 /var/log/asterisk/freepbx.log-20200319
102980 /var/log/asterisk/freepbx.log-20210505
102664 /var/log/asterisk/freepbx.log-20201207
102596 /var/log/asterisk/freepbx.log-20210717
48008 /var/cache/yum/x86_64/7/sng-base/gen/filelists_db.sqlite
38024 /var/cache/yum/x86_64/7/sng-epel/gen/primary_db.sqlite
36676 /var/cache/yum/x86_64/7-8.2003.3.el7.sangoma/sng-epel/gen/primary_db.sqlite
30872 /var/cache/yum/x86_64/7/sng-base/gen/primary_db.sqlite
30872 /var/cache/yum/x86_64/7-8.2003.3.el7.sangoma/sng-base/gen/primary_db.sqlite
22852 /var/log/asterisk/freepbx.log
22820 /var/cache/yum/x86_64/7-8.2003.3.el7.sangoma/sng-updates/gen/primary_db.sqlite
18700 /var/www/html/admin/modules/_cache/endpoint-15.0.23.tgz.gpg
18500 /var/log/asterisk/fail2ban
Average rating 0 (0 Votes)

You cannot comment on this entry