How to get this


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get this
# 1  
Old 11-22-2008
Question How to get this

Hi

I want to compare the output of below command to a numeric value, say 50.

df -k | grep abc | awk '{print $5}' | sed 's/.\{1\}$//g' >var

when i am taking this output in any variable, i am not able to use if [ $var -gt 50 ]

can some one plz hep me out in this.

Thanks in advance.
# 2  
Old 11-22-2008
Clasic:
Code:
df -k | awk '/abc/{print int($5)}'

# 3  
Old 11-22-2008
It gives output as zero, instead of 60, as it was giving before...
# 4  
Old 11-22-2008
What OS? try gawk or nawk
# 5  
Old 11-22-2008
it works with nawk, thanks

but i am not able to get the output printed.

df -k | nawk '/logs/{print int($5)}' > val

echo $val

if [ $val -gt 60 ]
then
echo "overlimit"
fi


can u plz help me on this.
# 6  
Old 11-22-2008
Code:
val=$(df -k | nawk '/logs/{print int($5)}')

# 7  
Old 11-22-2008
awesome !!!

thanks dude... it really Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question