if loop problem in bourne shell

how to use if-loop in bourne shell with multiple conditions like follows

if [ a > b && c > d ]
then
commands
fi

it gives me an error

test: ] missing

then i put
if [[ a > b && c > d ]]
it gives me an error
[[ not found

kindly i need the syntex for the bourne shell

Have you tried

if [ a > b ] && [ c > d ]

You must have an ancient version -

if [ $a -gt $b ] ; then
   if [ $c -gt $d ] ; then
   fi
fi

is what you will have to use.

The first example executes to TRUE, and prints "greater". The second example is FALSE, and nothing prints

> if [ 14 -gt 13  -a  15 -gt 12 ] ; then echo "greater"; fi
greater

> if [ 4 -gt 13  -a  5 -gt 12 ] ; then echo "greater"; fi

Seems I wasn't paying attention to the argument - just the format! Thanks Jim :slight_smile:

This is what it could look like:

if [ $a -gt $b ] && [ $c -gt $d ]

Thanks a lot guys , all the syntax worked fine except this one

if [ a > b ] && [ c > d ]

...thanks again :slight_smile: