LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   If statement - tcsh (https://www.linuxquestions.org/questions/linux-newbie-8/if-statement-tcsh-4175483496/)

sharon@ 11-05-2013 02:11 PM

If statement - tcsh
 
I need to loop through a bunch of different scenarios (variable scen), but can't figure out how to use the if statements in the tcsh shell script. Getting the error "if: Expression Syntax" Can someone please tell me what I have wrong? Simplified code follows! Thanks!

#!/bin/tcsh -f
#
set val = 0

foreach scen ( a b )

echo $scen

if ($scen==a) then
echo $scen
else
echo $val
endif

end

sharon@ 11-05-2013 03:43 PM

The if statement needs spaces,
e.g.
if($scen == a) then


All times are GMT -5. The time now is 11:58 PM.