awk command

Am trying to write a script that involves the use of df -k to work out filesystem usege.

this is were the problem is

basically

df -k |awk '/\// {print $5}' this produced the
following.

80%
90%
50%
60%

which is want I wanted but I also want
to remove the % sign.

I have tried df -k | grep "%" |awk '{printf("%s\n", $5)}' but this just produced the same output

I have search the forum for help but no joy
can you please help

Hi,

Try using sed, ie:

df -k |awk '/\// {print $5}' | sed 's/%//'

Hope this helps.

thank, this works fine.

Just a quick questing how do I
place the % back using a command to insert % back in.

Hassan,

You can add the % back in with the print command where you add the $5.

print $5, "\%"

You can use cut to separate the 80 from the %. Look at the man page for cut.

df -k |awk '/\// {print $5}' | cut "your command here"

:smiley:

thanks :cool: