Showing total disk use on Linux - a.k.a How to sum the output of df

If you want to find the total amount of disk space used on Linux, and other Unix based systems (such as OSX), you can do so quite easily with the following one liner...

df -lP | awk '{total+=$3} END {printf "%d G\n", total/2^20 + 0.5}'

What this does is...

This is particularly helpful if you have a lot of volumes on a system.

← Back to Blog