Hi anbody know where i'm wrong in?
#!/bin/ksh
ID1=1234
ID2=2345
ID3=3456
count=1
while [ "$count" -lt "4" ]
do
if [ eval echo \$ID$count = "1234" ];then
echo yeah
else
echo wrong
fi
count=$((count + 1))
done
Hi anbody know where i'm wrong in?
#!/bin/ksh
ID1=1234
ID2=2345
ID3=3456
count=1
while [ "$count" -lt "4" ]
do
if [ eval echo \$ID$count = "1234" ];then
echo yeah
else
echo wrong
fi
count=$((count + 1))
done
count=$(($count + 1))
...
if [ "$(eval echo \$ID$count)" = "1234" ];then
...
my count=$(($count + 1)) is correct...
this line is wrong... if [ eval echo \$ID$count = "1234" ];then
but if i use [ "$(eval echo \$ID$count)" = "1234" ] then the result will be ID1 which i want is ID1 value (1234)
you missed a "$" there as well
Not necessarily. Between $(( )) and (( )) variables are recognised with or without a $ prefix.
Oh, yes.
Sorry, I missed that out.
thank jlliagre it works... for if [ "$(eval echo \$ID$count)" = "1234" ];then