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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script problem

Status
Not open for further replies.

helo222

MIS
Feb 4, 2004
1
0
0
TW
I will monitor my HD.The scripe as blow.

#df -k|grep notes|awk '{printf "%s\n",$5}
#43%

Which command can help me to get number 43 not 43%?

Thank you.
 
Check out man page for 'cut'

I don't have a unix box here so working from memory....

set the percent symbol as the delimiter

#df -k|grep notes|awk '{printf "%s\n",$5} | cut -d'%' -f1

alternatively if you know the number will always be 2 characters long.

#df -k|grep notes|awk '{printf "%s\n",$5} | cut -c1-2

hope this helps

 
bonifale's reply for question works for the queries , it displays correct output
 
it works for monitoring disk space:
Code:
df -k  | grep ^/| sed 's/\%//g' | awk ' {print $5}'
 
oh.. previous post will give you all filesystems, for "notes" issue:
df -k | grep notes | sed 's/\%//g' | awk ' {print $5}'

sed statment will erase the '%' character.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top