IF syntax

Wai Yeung cheewai at spinifex.eecs.unsw.oz
Sun Dec 2 10:05:00 AEST 1990


In article <15796 at brahms.udel.edu>, jon at brahms.udel.edu (Jon Deutsch) writes:
> 
> #!/bin/sh
> if [$temp != '']  then
>         echo 'remote-caller' >> .people;
> else
> 	echo 'inside-caller' >> .people;
> fi
> 
The "then" has to be on the next line. Also, for [ ... ] to check for an
empty string, it isn't necessary to compare with "" (or '').

The following should work.
#
#!/bin/sh
if [ "$temp" ] # Note the quotes
then
    echo 'remote-caller' >> .people
else
    echo 'inside-caller' >> .people
fi
#

Chee Wai



More information about the Comp.unix.programmer mailing list