@
you're reading...
Linux Tips and Tricks

How to display File or Folder Sizes in a Current Directory in Human Readable Format

There are many ways on how to do it. You could use awk or perl but I like just using linux built-in tools. Will be giving two examples that I usually use.

1. use du and sort with the -g flag: result would be displayed in ascending order according to size
eg: du * | sort -g
du1
2. use du combined with sort, cut and xargs
eg: du -ks * | sort -nr | cut -f2 | xargs -d '\n' du -sh
du2

I like the second option as the result is more in human readable format.

Advertisements

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s