IF syntax
Hamish Macdonald
himacdon at maytag.uwaterloo.ca
Fri Nov 16 02:19:39 AEST 1990
>>>>> In article <965 at ksr.com>, harsha at ksr.com (Paul Harsha) writes:
Paul> You need to put the "then" on a seperate line
Paul> #!/bin/sh
Paul> if [$temp != '']
Paul> then
Paul> echo 'remote-caller' >> .people;
Paul> else
Paul> echo 'inside-caller' >> .people;
Paul> fi
How about 'can put the "then" on a separate line':
if [ "$temp" != "" ]; then
works just fine. The semicolon terminates the list of statements
forming the condition of the if.
I think there is a problem if you don't double-quote your variable or
leave white space around the "[" and "]" too:
1>@maytag[3]% echo a${temp}a
aa
1>@maytag[4]% if [$temp != '']; then echo blug; else echo bleah; fi
blug
It should echo "bleah"
1>@maytag[12]% if [ "$temp" != "" ]; then echo blug; else echo bleah; fi
bleah
Hamish.
--
--------------------------------------------------------------------
himacdon at maytag.uwaterloo.ca watmath!maytag!himacdon
More information about the Comp.unix.programmer
mailing list