# where am i wrong?

**URL:** <https://community.unix.com/t/where-am-i-wrong/211732>\
**Category:** Shell Programming and Scripting\
**Created:** [September 9, 2008, 2:41am UTC](https://community.unix.com/t/where-am-i-wrong/211732 "2008-09-09T02:41:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![summerpeh](https://community.unix.com/letter_avatar/summerpeh/32/5_5575768a8748004e209b776fc1b2916d.png) [@summerpeh](https://community.unix.com/u/summerpeh)\
**Post date:** [September 9, 2008, 2:41am UTC](https://community.unix.com/t/where-am-i-wrong/211732/1 "2008-09-09T02:41:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/5_5575768a8748004e209b776fc1b2916d.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [September 9, 2008, 2:48am UTC](https://community.unix.com/t/where-am-i-wrong/211732/2 "2008-09-09T02:48:19Z")

</div>

```nohighlight
count=$(($count + 1))

```

---

<div class="post-metadata">

**Author:** ![jlliagre](https://community.unix.com/letter_avatar/jlliagre/32/5_5575768a8748004e209b776fc1b2916d.png) [@jlliagre](https://community.unix.com/u/jlliagre)\
**Post date:** [September 9, 2008, 2:49am UTC](https://community.unix.com/t/where-am-i-wrong/211732/3 "2008-09-09T02:49:38Z")

</div>

```nohighlight
...
if ["$(eval echo \$ID$count)" = "1234"];then
...

```

---

<div class="post-metadata">

**Author:** ![summerpeh](https://community.unix.com/letter_avatar/summerpeh/32/5_5575768a8748004e209b776fc1b2916d.png) [@summerpeh](https://community.unix.com/u/summerpeh)\
**Post date:** [September 9, 2008, 2:50am UTC](https://community.unix.com/t/where-am-i-wrong/211732/4 "2008-09-09T02:50:19Z")

</div>

my count=$(($count + 1)) is correct...

this line is wrong... if [eval echo \$ID$count = "1234"];then

---

<div class="post-metadata">

**Author:** ![summerpeh](https://community.unix.com/letter_avatar/summerpeh/32/5_5575768a8748004e209b776fc1b2916d.png) [@summerpeh](https://community.unix.com/u/summerpeh)\
**Post date:** [September 9, 2008, 2:53am UTC](https://community.unix.com/t/where-am-i-wrong/211732/5 "2008-09-09T02:53:03Z")

</div>

but if i use ["$(eval echo \$ID$count)" = "1234"] then the result will be ID1 which i want is ID1 value (1234)

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/5_5575768a8748004e209b776fc1b2916d.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [September 9, 2008, 2:53am UTC](https://community.unix.com/t/where-am-i-wrong/211732/6 "2008-09-09T02:53:04Z")

</div>

> [@](#):
>
> my count=$(($count + 1)) is correct...

you missed a "$" there as well

---

<div class="post-metadata">

**Author:** ![Annihilannic](https://community.unix.com/user_avatar/community.unix.com/annihilannic/32/4183_2.png) [@Annihilannic](https://community.unix.com/u/Annihilannic)\
**Post date:** [September 9, 2008, 3:03am UTC](https://community.unix.com/t/where-am-i-wrong/211732/7 "2008-09-09T03:03:04Z")

</div>

> [@matrixmadhan](#):
>
> you missed a "$" there as well

Not necessarily. Between $(( )) and (( )) variables are recognised with or without a $ prefix.

---

<div class="post-metadata">

**Author:** ![matrixmadhan](https://community.unix.com/letter_avatar/matrixmadhan/32/5_5575768a8748004e209b776fc1b2916d.png) [@matrixmadhan](https://community.unix.com/u/matrixmadhan)\
**Post date:** [September 9, 2008, 3:22am UTC](https://community.unix.com/t/where-am-i-wrong/211732/8 "2008-09-09T03:22:41Z")

</div>

> [@annihilannic](#):
>
> Not necessarily. Between $(( )) and (( )) variables are recognised with or without a $ prefix.

Oh, yes. :b:

Sorry, I missed that out.

---

<div class="post-metadata">

**Author:** ![summerpeh](https://community.unix.com/letter_avatar/summerpeh/32/5_5575768a8748004e209b776fc1b2916d.png) [@summerpeh](https://community.unix.com/u/summerpeh)\
**Post date:** [September 9, 2008, 4:11am UTC](https://community.unix.com/t/where-am-i-wrong/211732/9 "2008-09-09T04:11:49Z")

</div>

thank jlliagre it works... for if ["$(eval echo \$ID$count)" = "1234"];then
