Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

have the space availble on the hard disk

Status
Not open for further replies.

donny750

Programmer
Jul 13, 2006
145
FR
hello,

To obtain the size avaible on the hard disk i use this :
Code:
 df -k .

and i obtain that
Filesystem 1K-blocks Used Available Use% Mounted on
/prof/root/home 324258 294614 221614 59% /home

how can i do to have just the numeric value of the avaible space : 221614 ??

It's possible ?

thanks
 
Hi,

use awk and grep $4 stay for the fourth column
Code:
df -k .|grep -v Used|awk '{print $4}'

Ali
 
Hi

Only with [tt]df[/tt] no way. You have to cut out the needed part with an adequate tool.
Code:
df -k . | awk 'NR==2{print $4}'
aau, uuog police is around...

Feherke.
 
aau, you never need to use grep and awk together:

[tt]df -k . | awk '!/Used/{print $4}'[/tt]

or in this particular example:

[tt]df -k . | awk 'NR>1{print $4}'[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top