Monday, February 16, 2015

File systems usage in UNIX

It is hard to parse the output of the df unix command with the human eye. So I have written a simple solution for it. The following command will fetch you the list of filesystem whose usage is greater than eighty percent in descending order.
df -g | awk '{print $4 "\t" $7}' | sort -nrk 1 | egrep "([89][0-9]|100)%"
Output will be like this:
85% /filesystem1
82% /filesystem2
82% /filesystem3
81% /filesystem4

You can remove the final egrep to view all the file systems. Like this:
df -g | awk '{print $4 "\t" $7}' | sort -nrk 1
Feel free to comment below!

No comments:

Post a Comment