Tip: how to get the size of a folder in Linux CLI

It seems like a simple request…and it mostly is. But if you want to get the size of a folder – including sub-folders – in Linux from the command line, you need to use the du command. The simplest trick (thanks linuxforums.org) to get the total size without listing all the sub-folders is to use the following:

du -h | grep -v '/' | awk '{print $1}'
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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