Show: if.csh

#!/usr/bin/env csh 


#	Purpose: To demonstrate the usage of if and foreach in C Shell (csh).
#	Author:  Wahid Lutfy
#	CopyRight © MyWebUnivesity.com


#  Print a list of sports

foreach sport ( Soccer Football Swimming Running Basketball Handball Teniss VoleyBall )
echo $sport
if ( $sport == "Soccer" ) then
echo "I love playing $sport!"
endif

end

#  Print a list of characters, upper-case, lower-case and numbers.
 
foreach ch ( A B C D E F a b c d e f 1 2 3 4 5 )
echo " I am printing all the characters first $ch"
if (( $ch == 'D' ) || ( $ch == 'd' ) || ( $ch == '5' )) then
echo " I am interested in either 'D', 'd', or '5' "
echo "$ch was found"
endif
end

#  Print a list of fruits
 
foreach fruit ( Apple Bannana Grape Orange Pear )
if ( $fruit == "Bannana" ) then
echo "Did you know Bannana is called Kela in Dari language?"
endif
echo $fruit

end