in bash how do I parse out the available disk space from df ?

TIMFOX123
TIMFOX123 used Ask the Experts™
on
df -h /tmp | grep tmp

I just want to pull out the available disk space :)

i
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
swap                    29G   150M    29G     1%    /tmp

29 gigs availabe  
Most Valuable Expert 2013
Top Expert 2013

Commented:
df -h /tmp | grep tmp  |awk '{print $3}'
Most Valuable Expert 2013
Top Expert 2013
Commented:
Sorry, there'a first column, obviously :-))

df -h /tmp | grep tmp  |awk '{print $4}'
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Try:

df -h /tmp | awk '$1 !~ /Filesystem/ {print $4}'

This basically prints the fourth column of any lines output from df that do not have the word Filesystem as the first column.
or print both available and % of whole

 df -h /tmp | grep /tmp | awk '{ print $3" "$4 }'


Author

Commented:
thank you all

Great job

I look good at work however I owe it all to this team

thx again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial