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!

re: scripting question

Status
Not open for further replies.

thutmose

MIS
Mar 31, 2002
24
US
Hey,


I know this might sounds elementary but I am trying to compare an integer to the output of a command and its not working EX:


#!/bin/sh
#
#
x=200
y=`du-sk | nawk '{print $1}'`

#this is where everything goes blank here trying to compare
#these 2 variables here.

while "$x" >= "$y"
do

#I am not having problems with this part of the script.



done
 
I can see 2 problems:

1) du-sk - I assume this should be 'du -sk'
2) while "$x" >= "$y" - should be 'while [ $x -ge "$y" ]'

 
ok,



That was a typo with the du-dk which I had been putting in du -sk. However, with the brackets its still not working.
 
don't put quotes around integers
unless you want them treated like a string.
I also added brackets around the equation. [ ]



#!/bin/sh
#
#
x=500
y=`du -sk|nawk '{print $1}'`

#this is where everything goes blank here trying to compare
#these 2 variables here.

echo "x: $x"
echo "y: $y"
while [ $x -ge $y ]
do
echo "hello there!"
done
Robert G. Jordan

Robert@JORDAN2000.com
Unix Sys Admin
Chicago, Illinois U.S.A.
[lightsaber]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top