Skip to main content

Bash Cheat Sheet

Comparison operators

 Operator  Description   Operator Description
-eq Is equal to   -n Is not null
-ne Is not equal to   -z Is null
-gt Is greater than      
-ge Is greater than or equal to      
-lt Is less then      
-le Is less than or equal to      
== is equal to      
!= is not equal to      
< Is less than      
<= Is less than or equal to      
> Is greater then      
>= Is greater than or equal to      

Variables for script arguments

 Variable Description VariableDescription
$1 ... $nArgument number $#Number of arguments
$0Name of the file $?Return value (0 = ok, > 0 = error)
$*List of arguments