To see human readable output, I can use the following command – du command -h option : Display sizes in human readable format (e.g., 1K, 234M, 2G).

$ du -hsx * | sort -rh | head -10

The sample output would look like

4.4G   Desktop
3.8G   Downloads
149M   en-GB
146M   Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
95M   scala-2.11.4.deb
20M   gawk-4.1.1
4.5M   linux-dash
3.9M   yii-1.1.13.e9e4a0.tar.gz.1
3.9M   yii-1.1.13.e9e4a0.tar.gz

How can I use the Find command to get the readable file sizes?

Example: To skip directories and only display files, use the following command

find . -type f -printf '%s %p\n'| sort -nr | head -4

Gives me:

185016320 ./Desktop/gdb-7.9.tar
153300495 ./Downloads/apache-storm-1.0.0.tar.gz
152847886 ./Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
98756608 ./scala-2.11.4.deb

I'm trying to get the file sizes to show up as 185M, 153M, etc.. (more readable)


Use numfmt

find . -type f -printf '%s %p\n'| sort -nr | head -4 | numfmt --field=1 --to=iec


177M ./Desktop/gdb-7.9.tar
147M ./Downloads/apache-storm-1.0.0.tar.gz
146M ./Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
95M ./scala-2.11.4.deb

Use --to=si if you want factor 1000 instead of 1024

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.