awk in df -k output. (145 Views)
Frequent Advisor
Posts: 99
Registered: ‎06-20-2013
Message 1 of 2 (145 Views)

awk in df -k output.



$ bdf /tmp /usr /var |grep -v "Filesystem"|grep "%"|awk '{print $NF, $(NF-1)}'

/tmp 9%
/usr 37%
/var 50%

I am able to get File system usage correctly using bdf as what I expected.


I need the output to be same for df -k as bdf output.


I tried using different ways to df -k ,but i am not able to get the df -k output as same as bdf.



Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,744
Registered: ‎03-06-2006
Message 2 of 2 (137 Views)

Re: awk in df -k output.

Why would you ever want to use df when you have bdf?

You may want to look at Bill's bdfmegs:


But this should work:

df -k | awk '
substr($0, 1, 1) != " " {
   name = $1
/%/ {
   print name, $1 $2

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation