The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-10-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
Remember, it is always commandline = argument delimeter.
test ( = [ ) is command, ... [ ] are not bracket as in some programming languages.
if need if-block end = fi.
Also use always "" with variable. Why ? If variable is empty, you get error, but if it is "$variable", it's always string with length >= 0.

Code:
if  [  "$X" = "Today is holiday."  ]
then 
   echo "i dont need to go to ofc"
else
   echo "i need to go to ofc"
fi

Double bracket is different command as single = differerent arguments and so on.

more about if, testing, ...

Last edited by kshji; 07-10-2009 at 04:00 AM.. Reason: Fixing