# Error while implementing nested if

**URL:** <https://community.unix.com/t/error-while-implementing-nested-if/285477>\
**Category:** Shell Programming and Scripting\
**Created:** [March 30, 2011, 4:05am UTC](https://community.unix.com/t/error-while-implementing-nested-if/285477 "2011-03-30T04:05:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagarrd](https://community.unix.com/letter_avatar/sagarrd/32/5_5575768a8748004e209b776fc1b2916d.png) [@sagarrd](https://community.unix.com/u/sagarrd)\
**Post date:** [March 30, 2011, 4:05am UTC](https://community.unix.com/t/error-while-implementing-nested-if/285477/1 "2011-03-30T04:05:56Z")

</div>

considering all variables like S01DEPOSITS will return numbers, i am trying to execute below statement

```nohighlight
if [[\( "$1" >= "${S01DEPOSITS}" -a "$1" <= "${E01DEPOSITS}" \) -o \( "$1" >= ${S04OVERDRAFT} -a "$1" <= ${E04OVERDRAFT} \) -o \( "$1" >= ${S05DEPOSITS} -a "$1" <= ${E05DEPOSITS} \) -o \( "$1" >= ${S23DEPOSITS} -a "$1" <= ${E23DEPOSITS} \) -o \( "$1" >= ${S25DEPOSITS} -a "$1" <= ${E25DEPOSITS} \) -o \( "$1" >= ${S33DEPOSITS} -a "$1" <= ${E33DEPOSITS} \) -o \( "$1" >= ${S26TLR_MAINT} -a "$1" <= ${E26TLR_MAINT} \)]]
then
  echo "Queue DEP"
fi

```

while executing above if statement i am getting error as

```nohighlight
if [[\( "$1" qcheck.sh[100]: Syntax error at line 100 : `"$1"' is not expected.

```

pls help as soon as possible thanks

---

<div class="post-metadata">

**Author:** ![Franklin52](https://community.unix.com/user_avatar/community.unix.com/franklin52/32/500_2.png) [@Franklin52](https://community.unix.com/u/Franklin52)\
**Post date:** [March 30, 2011, 4:59am UTC](https://community.unix.com/t/error-while-implementing-nested-if/285477/2 "2011-03-30T04:59:23Z")

</div>

Try one of these syntaxes:

```nohighlight
[condition1 -a condition2] # ( condition1 AND condition2)
[condition1 -o condition2] # ( condition1 OR condition2)

```

or:

```nohighlight
[[condition1 && condition2]] # ( condition1 AND condition2)
[[condition1 || condition2]] # ( condition1 OR condition2)

```

---

<div class="post-metadata">

**Author:** ![michaelrozar17](https://community.unix.com/user_avatar/community.unix.com/michaelrozar17/32/1975_2.png) [@michaelrozar17](https://community.unix.com/u/michaelrozar17)\
**Post date:** [March 30, 2011, 5:10am UTC](https://community.unix.com/t/error-while-implementing-nested-if/285477/3 "2011-03-30T05:10:34Z")

</div>

Additionally if you are comparing numbers then use -ge or -gt operator and remove the quotes surrounding $1.

```nohighlight
if [[$1 -ge "${S01DEPOSITS}" && $1 -le "${E01DEPOSITS}" ...]]
# ge -- greater than or equal to
# le -- less than or equal to

```

---

<div class="post-metadata">

**Author:** ![sagarrd](https://community.unix.com/letter_avatar/sagarrd/32/5_5575768a8748004e209b776fc1b2916d.png) [@sagarrd](https://community.unix.com/u/sagarrd)\
**Post date:** [March 30, 2011, 5:58am UTC](https://community.unix.com/t/error-while-implementing-nested-if/285477/4 "2011-03-30T05:58:13Z")

</div>

Thanks michaelrozar17 and Franklin52 its working now...!!! :D:D:D :b:
