Sum up disk space where each partition is above 10G


I want to do a df and add all partitions above 10 GB and get the sum. How can I do that?

This will add all the paritions, but I can’t pass my condition.

df -h | grep G| awk ‘{s+=$4} END {print s}’.

So what I need is, I will do a df , the get the space details and add them up if they are above 10G. I need to do it in a single line, because this need to be fed to a remote redis


Here you go:
df -h | grep G | awk {' print int($4) '} | sed 's/G//' | awk '$1>10' | awk '{s+=$1} END {print s}'

This can be optimized but I made it in a hurry, you can take the idea from it.

The use of “awk {’ print int($4) '}” to round numbers like 6.3, 1.1 and so on.
The use of “sed ‘s/G//’” to remove the G character from the disk space.
The use of “awk ‘$1>10’” to get numbers over than 10 GB.
The use of “awk ‘{s+=$1} END {print s}’” to count total.

Best Regards,