1,885
edits
Changes
→Setting the Exit Status when Exiting from a Shell Script
Will exit the script with an exit code of 2.
= The test ([) Command =
BASH has a built-in test command (similar to <code>/bin/test</code>) which can perform basic string and integer comparisons using these operators:
{|class="mediawiki" border="1"
|-
!Operator
!Comparision type
!Comparison
!Example
|-
|<nowiki>-eq</nowiki>
|Integer
|Equal
|$x -eq 4
|-
|<nowiki>-ne</nowiki>
|Integer
|Not equal
|$x -ne 4
|-
|<nowiki>-gt</nowiki>
|Integer
|Greater than
|$x -gt 0
|-
|<nowiki>-lt</nowiki>
|Integer
|Less than
|$x -lt 1000
|-
|<nowiki>-ge</nowiki>
|Integer
|Greater than or equal to
|$x -ge $y
|-
|<nowiki>-le</nowiki>
|Integer
|Less than or equal to
|$x -le 96
|-
|=
|String
|Equal
|"$x" = "Y"
|-
|!=
|String
|Not equal
|"$x" != "NEVER"
|}
= Exit Codes and Flow Control =