Type in a command, or "ls dictionary" to search all commands for "dictionary", etc.
|
NAME if - compare two values and return a value based on the result. SYNOPSIS if <value1> [-lt|gt|le|ge|eq|ne <value2>] [-then <result1>] [-else <result2>] [-follow True|False] EXAMPLES if 1 -lt 2 -then yes -else no (returns "yes" since "1" is less than "2") if -eq ${var} -then yes -else no (returns "yes" if var is empty, "no" otherwise) if True -then yes -else no (returns "yes") if False -then yes -else no (returns "no") if abc -eq bcd -then http://google.com -else http://yahoo.com -follow True (returns the Yahoo! webpage) DESCRIPTION Either compares two values, or checks for the truth of a value. All values other than "False", "No", "0" and "" are interpreted as True. Permitted comparisons are: -lt (Less Than) -gt (Greater Than) -le (Less than or Equal) -ge (Greater than or Equal) -eq (EQual) -ne (Not Equal) When checking if a variable is empty, the variable has to be specified behind the comparison switch: if -eq ${var} -then yes -else no The following WILL NOT work: if ${var} -eq -then yes -else no If the -follow switch is set to "True", if tries to follow links that begin with "http://". The default setting for -follow is "False". AUTHOR Samuel Hoffstaetter "http://shoffsta.linuxside.org/" based on "IfThen" by Allen Ormond <aormond (at) fromrocks (dot) com>