Newsgroups: comp.unix.programmer Path: utzoo!utgpu!watserv1!maytag!maytag!himacdon From: himacdon@maytag.uwaterloo.ca (Hamish Macdonald) Subject: Re: IF syntax In-Reply-To: harsha@ksr.com's message of 14 Nov 90 18:39:40 GMT Message-ID: <1990Nov15.151939.21008@maytag.waterloo.edu> Sender: daemon@maytag.waterloo.edu (Admin) Organization: University of Waterloo, Waterloo, Ontario References: <15796@brahms.udel.edu> <965@ksr.com> Date: Thu, 15 Nov 90 15:19:39 GMT Lines: 36 >>>>> In article <965@ksr.com>, harsha@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@maytag.uwaterloo.ca watmath!maytag!himacdon