I have changed the code..
#! /bin/sh
prev_Ixref=245
curr_Ixref=355
while ("$prev_Ixref" -lt "245" -a "$prev_Ixref" -gt "355")
do
echo "curr_Ixref is $curr_Ixref"
echo "prev_Ixref is $prev_Ixref"
curr_Ixref=curr_Ixref+1
prev_Ixref=prev_Ixref+1
done
Still it is giving the same error..
could you please help me out..
You are still using round parentheses in the while although viyadhar85 already pointed out how to correct it.
("$prev_Ixref") in round parentheses means run the command "$prev_Ixref" in a subshell. That's not what you want.
The syntax of the while loop is while command; do ... done and the command should be your comparison test. The [ command (sic) is also known as test and is used to perform arithmetic comparisons (among a number of other things).
The way you set it up, it's not less than 245, so this should hardly be surprising. It's also not clear under what circumstances you could expect the same number to be less than 245 and greater than 355 at the same time. What do you want it to do, exactly?
Era,
Thanks tats the mistake on my part..
it should be
while [ "$prev_Ixref" -gt "245" -a "$prev_Ixref" -lt "355" ]
like this..
thanks for that..
currently i am having a problem in network..once its done.. i ll let u knw the results..
guys, the script ran successfully guys,,
no i ll start to build my actual requirements on it..
guys actually i have to update a column..
the column is a number which is auto generated..
Lets say the column is currently having 245,
then i have to update it with 355..
so in the place of echo.. i am goin to write this code..
db2 -v "update tablename set column_name = $prev_Ixref \
where column_name= $curr_Ixref "
vidayadhar,, am talkin abt updating 8 crore records, which i cant do it in a single go,,
so i have to do it only 5 lakh records at a time..
i will do a commit after that and repeat the update query again..
I hadn't heard crore before -- perhaps it would be wise to avoid regional jargon.
It's not really clear how your small script relates to the problem in question. You want to issue 50,000 commands to increment an index by 110, then commit, repeat 160 times?
for base in 245 50245 100245; do # add 157 more or write another loop ...
perl -le 'for (0..49999) {
print "update whatever where value ", $ARGV[0]+$_, " with value ", $ARGV[0]+$_+110 }' $base |
less # replace with db2 if this looks correct
done