-
-
Save emphazer/42cd1bb253bf3939d0f15ed1784dc96c to your computer and use it in GitHub Desktop.
Revisions
-
magnetikonline revised this gist
Oct 26, 2017 . 1 changed file with 14 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,14 @@ # Bash if expressions cheatsheet - Table - [String](#table-string) - [Integer](#table-integer) - [File system](#table-file-system) - [File compare modification/exists](#table-file-compare-modification-exists) - [Combine expressions](#table-combine-expressions) - [Notes](#notes) - [Reference](#reference) <table> <tr> <th colspan="2">Boolean</th> @@ -19,7 +28,7 @@ if [[ ! $VAR ]] </pre></td> </tr> <tr> <th colspan="2" id="table-string">String</th> </tr> <tr> <td>Is equal</td> @@ -55,7 +64,7 @@ if [[ ! $VAR ]] </tr> <tr> <th colspan="2" id="table-integer">Integer</th> </tr> <tr> <td>Is equal</td> @@ -83,7 +92,7 @@ if [[ ! $VAR ]] </tr> <tr> <th colspan="2" id="table-file-system">File system</th> </tr> <tr> <td>Is file (file, dir, symlink, anything)</td> @@ -123,7 +132,7 @@ if [[ ! $VAR ]] </tr> <tr> <th colspan="2" id="table-file-compare-modification-exists">File compare modification/exists</th> </tr> <tr> <td> @@ -141,7 +150,7 @@ if [[ ! $VAR ]] </tr> <tr> <th colspan="2" id="table-combine-expressions">Combine expressions</th> </tr> <tr> <td>If <code>EXPR1</code> and <code>EXPR2</code> are true</td> -
magnetikonline revised this gist
Jul 31, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,7 +163,7 @@ if [[ ! $VAR ]] ## Notes - `*`: Use of `:` here as a NOP operation, which will always return true. - `**`: Regular expression captures available via [array](http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_02.html) `${BASH_REMATCH[*]}`, `${BASH_REMATCH[1]}`, etc. ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. -
magnetikonline revised this gist
Jul 31, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,7 +163,7 @@ if [[ ! $VAR ]] ## Notes - `*`: Use of `:` here as a NOP operation, which will always return true. - `**`: Regular expression captures available via `${BASH_REMATCH[*]}`, `${BASH_REMATCH[1]}`, etc. ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. -
magnetikonline revised this gist
Apr 25, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,14 +8,14 @@ <td>Is true <code>*</code></td> <td><pre> VAR=: if [[ $VAR ]] </pre></td> </tr> <tr> <td>Is false</td> <td><pre> VAR= if [[ ! $VAR ]] </pre></td> </tr> <tr> -
magnetikonline revised this gist
Apr 25, 2017 . 1 changed file with 23 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,23 @@ # Bash if expressions cheatsheet <table> <tr> <th colspan="2">Boolean</th> </tr> <tr> <td>Is true <code>*</code></td> <td><pre> VAR=: [[ $VAR ]] && echo "true" </pre></td> </tr> <tr> <td>Is false</td> <td><pre> VAR= [[ ! $VAR ]] && echo "false" </pre></td> </tr> <tr> <th colspan="2">String</th> </tr> @@ -29,11 +46,11 @@ <td><code>if [[ $VAR1 > $VAR2 ]]</code></td> </tr> <tr> <td>Regular expression <code>**</code></td> <td><code>if [[ $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <td>Regular expression not <code>**</code></td> <td><code>if [[ ! $VAR =~ ^my.+regexp$ ]]</code></td> </tr> @@ -145,9 +162,11 @@ </table> ## Notes - `*`: Use of `:` here as a NOP operation, which will always return true. - `**`: Regular expression captures available via `$BASH_REMATCH`, `${BASH_REMATCH[1]}`, etc. ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. - Difference between `[ ]` and `[[ ]]`: http://mywiki.wooledge.org/BashFAQ/031. - Bash NOP (no op) `:`: https://en.wikipedia.org/wiki/NOP#Shell_Scripting_.28bash.2C_zsh.2C_etc.29. - GNU Bash reference manual: http://www.gnu.org/software/bash/manual/bashref.html. -
magnetikonline revised this gist
Mar 21, 2017 . 1 changed file with 137 additions and 137 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,147 +1,147 @@ # Bash if expressions cheatsheet <table> <tr> <th colspan="2">String</th> </tr> <tr> <td>Is equal</td> <td><code>if [[ $VAR1 == $VAR2 ]]</code></td> </tr> <tr> <td>Not equal</td> <td><code>if [[ $VAR1 != $VAR2 ]]</code></td> </tr> <tr> <td>Is empty / zero length</td> <td><code>if [[ -z $VAR ]]</code></td> </tr> <tr> <td>Not empty / non-zero length</td> <td><code>if [[ -n $VAR ]]</code></td> </tr> <tr> <td>Less than (ASCII alpha)</td> <td><code>if [[ $VAR1 < $VAR2 ]]</code></td> </tr> <tr> <td>Greater than (ASCII alpha)</td> <td><code>if [[ $VAR1 > $VAR2 ]]</code></td> </tr> <tr> <td>Regular expression <code>*</code></td> <td><code>if [[ $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <td>Regular expression not <code>*</code></td> <td><code>if [[ ! $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <th colspan="2">Integer</th> </tr> <tr> <td>Is equal</td> <td><code>if [[ $VAR1 -eq $VAR2 ]]</code></td> </tr> <tr> <td>Not equal</td> <td><code>if [[ $VAR1 -ne $VAR2 ]]</code></td> </tr> <tr> <td>Less than</td> <td><code>if [[ $VAR1 -lt $VAR2 ]]</code></td> </tr> <tr> <td>Less than or equal</td> <td><code>if [[ $VAR1 -le $VAR2 ]]</code></td> </tr> <tr> <td>Greater than</td> <td><code>if [[ $VAR1 -gt $VAR2 ]]</code></td> </tr> <tr> <td>Greater than or equal</td> <td><code>if [[ $VAR1 -ge $VAR2 ]]</code></td> </tr> <tr> <th colspan="2">File system</th> </tr> <tr> <td>Is file (file, dir, symlink, anything)</td> <td><code>if [[ -e $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file</td> <td><code>if [[ -f $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is readable</td> <td><code>if [[ -r $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is writable</td> <td><code>if [[ -w $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is executable</td> <td><code>if [[ -x $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, not zero size</td> <td><code>if [[ -s $FILE_PATH ]]</code></td> </tr> <tr> <td>Is directory</td> <td><code>if [[ -d $FILE_PATH ]]</code></td> </tr> <tr> <td>Is symlink</td> <td><code>if [[ -h $FILE_PATH ]]</code></td> </tr> <tr> <td>Is socket</td> <td><code>if [[ -S $FILE_PATH ]]</code></td> </tr> <tr> <th colspan="2">File modification/exists compare</th> </tr> <tr> <td> Is <code>FILE1</code> newer than <code>FILE2</code><br /> ...or <code>FILE1</code> exists and <code>FILE2</code> does not </td> <td><code>if [[ $FILE1 -nt $FILE2 ]]</code></td> </tr> <tr> <td> Is <code>FILE1</code> older than <code>FILE2</code><br /> ...or <code>FILE2</code> exists and <code>FILE1</code> does not </td> <td><code>if [[ $FILE1 -ot $FILE2 ]]</code></td> </tr> <tr> <th colspan="2">Combine expressions</th> </tr> <tr> <td>If <code>EXPR1</code> and <code>EXPR2</code> are true</td> <td><code>if [[ (EXPR1) && (EXPR2) ]]</code></td> </tr> <tr> <td>If <code>EXPR1</code> and <code>EXPR2</code> are true</td> <td><code>if [ (EXPR1) -a (EXPR2) ]</code></td> </tr> <tr> <td>If <code>EXPR1</code> or <code>EXPR2</code> are true</td> <td><code>if [[ (EXPR1) || (EXPR2) ]]</code></td> </tr> <tr> <td>If <code>EXPR1</code> or <code>EXPR2</code> are true</td> <td><code>if [ (EXPR1) -o (EXPR2) ]</code></td> </tr> </table> ## Notes -
magnetikonline revised this gist
Jan 29, 2017 . 1 changed file with 23 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,76 +70,82 @@ </tr> <tr> <td>Is file (file, dir, symlink, anything)</td> <td><code>if [[ -e $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file</td> <td><code>if [[ -f $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is readable</td> <td><code>if [[ -r $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is writable</td> <td><code>if [[ -w $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, is executable</td> <td><code>if [[ -x $FILE_PATH ]]</code></td> </tr> <tr> <td>Is regular file, not zero size</td> <td><code>if [[ -s $FILE_PATH ]]</code></td> </tr> <tr> <td>Is directory</td> <td><code>if [[ -d $FILE_PATH ]]</code></td> </tr> <tr> <td>Is symlink</td> <td><code>if [[ -h $FILE_PATH ]]</code></td> </tr> <tr> <td>Is socket</td> <td><code>if [[ -S $FILE_PATH ]]</code></td> </tr> <tr> <th colspan="2">File modification/exists compare</th> </tr> <tr> <td> Is <code>FILE1</code> newer than <code>FILE2</code><br /> ...or <code>FILE1</code> exists and <code>FILE2</code> does not </td> <td><code>if [[ $FILE1 -nt $FILE2 ]]</code></td> </tr> <tr> <td> Is <code>FILE1</code> older than <code>FILE2</code><br /> ...or <code>FILE2</code> exists and <code>FILE1</code> does not </td> <td><code>if [[ $FILE1 -ot $FILE2 ]]</code></td> </tr> <tr> <th colspan="2">Combine expressions</th> </tr> <tr> <td>If <code>EXPR1</code> and <code>EXPR2</code> are true</td> <td><code>if [[ (EXPR1) && (EXPR2) ]]</code></td> </tr> <tr> <td>If <code>EXPR1</code> and <code>EXPR2</code> are true</td> <td><code>if [ (EXPR1) -a (EXPR2) ]</code></td> </tr> <tr> <td>If <code>EXPR1</code> or <code>EXPR2</code> are true</td> <td><code>if [[ (EXPR1) || (EXPR2) ]]</code></td> </tr> <tr> <td>If <code>EXPR1</code> or <code>EXPR2</code> are true</td> <td><code>if [ (EXPR1) -o (EXPR2) ]</code></td> </tr> </table> ## Notes - `*`: Regular expression captures available via `$BASH_REMATCH`, `${BASH_REMATCH[1]}`, etc. ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. -
magnetikonline revised this gist
Apr 18, 2016 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,11 +29,11 @@ <td><code>if [[ $VAR1 > $VAR2 ]]</code></td> </tr> <tr> <td>Regular expression <code>*</code></td> <td><code>if [[ $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <td>Regular expression not <code>*</code></td> <td><code>if [[ ! $VAR =~ ^my.+regexp$ ]]</code></td> </tr> @@ -138,6 +138,9 @@ </tr> </table> ## Notes - `*`: Regular expression captures will be available in `$BASH_REMATCH`, `${BASH_REMATCH[1]}`, `${BASH_REMATCH[2]}`, etc. ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. - Difference between `if [ ]` and `if [[ ]]` tests: http://mywiki.wooledge.org/BashFAQ/031. -
magnetikonline revised this gist
Oct 26, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -122,19 +122,19 @@ </tr> <tr> <td>If EXPR1 and EXPR2 are true</td> <td><code>if [[ (EXPR1) && (EXPR2) ]]</code></td> </tr> <tr> <td>If EXPR1 and EXPR2 are true</td> <td><code>if [ (EXPR1) -a (EXPR2) ]</code></td> </tr> <tr> <td>If EXPR1 or EXPR2 are true</td> <td><code>if [[ (EXPR1) || (EXPR2) ]]</code></td> </tr> <tr> <td>If EXPR1 or EXPR2 are true</td> <td><code>if [ (EXPR1) -o (EXPR2) ]</code></td> </tr> </table> -
magnetikonline revised this gist
Oct 2, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,6 +88,10 @@ <td>Is regular file, is executable</td> <td><code>if [[ -x $FILEPATH ]]</code></td> </tr> <tr> <td>Is regular file, not zero size</td> <td><code>if [[ -s $FILEPATH ]]</code></td> </tr> <tr> <td>Is directory</td> <td><code>if [[ -d $FILEPATH ]]</code></td> -
magnetikonline revised this gist
Sep 15, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -105,11 +105,11 @@ <th colspan="2">File modification/exists compare</th> </tr> <tr> <td>Is FILE1 newer than FILE2<br />...or FILE1 exists and FILE2 does not</td> <td><code>if [[ $FILE1 -nt $FILE2 ]]</code></td> </tr> <tr> <td>Is FILE1 older than FILE2<br />...or FILE2 exists and FILE1 does not</td> <td><code>if [[ $FILE1 -ot $FILE2 ]]</code></td> </tr> -
magnetikonline revised this gist
Sep 15, 2015 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -101,6 +101,18 @@ <td><code>if [[ -S $FILEPATH ]]</code></td> </tr> <tr> <th colspan="2">File modification/exists compare</th> </tr> <tr> <td>Is FILE1 newer than FILE2 - or FILE1 exists and FILE2 does not</td> <td><code>if [[ $FILE1 -nt $FILE2 ]]</code></td> </tr> <tr> <td>Is FILE1 older than FILE2 - or FILE2 exists and FILE1 does not</td> <td><code>if [[ $FILE1 -ot $FILE2 ]]</code></td> </tr> <tr> <th colspan="2">Combine expressions</th> </tr> -
magnetikonline revised this gist
Aug 28, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -124,5 +124,5 @@ ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. - Difference between `if [ ]` and `if [[ ]]` tests: http://mywiki.wooledge.org/BashFAQ/031. - GNU Bash reference manual: http://www.gnu.org/software/bash/manual/bashref.html. -
magnetikonline revised this gist
Aug 9, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,10 @@ <td>Is equal</td> <td><code>if [[ $VAR1 == $VAR2 ]]</code></td> </tr> <tr> <td>Not equal</td> <td><code>if [[ $VAR1 != $VAR2 ]]</code></td> </tr> <tr> <td>Is empty / zero length</td> <td><code>if [[ -z $VAR ]]</code></td> -
magnetikonline revised this gist
Jun 5, 2015 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,35 +66,35 @@ </tr> <tr> <td>Is file (file, dir, symlink, anything)</td> <td><code>if [[ -e $FILEPATH ]]</code></td> </tr> <tr> <td>Is regular file</td> <td><code>if [[ -f $FILEPATH ]]</code></td> </tr> <tr> <td>Is regular file, is readable</td> <td><code>if [[ -r $FILEPATH ]]</code></td> </tr> <tr> <td>Is regular file, is writable</td> <td><code>if [[ -w $FILEPATH ]]</code></td> </tr> <tr> <td>Is regular file, is executable</td> <td><code>if [[ -x $FILEPATH ]]</code></td> </tr> <tr> <td>Is directory</td> <td><code>if [[ -d $FILEPATH ]]</code></td> </tr> <tr> <td>Is symlink</td> <td><code>if [[ -h $FILEPATH ]]</code></td> </tr> <tr> <td>Is socket</td> <td><code>if [[ -S $FILEPATH ]]</code></td> </tr> <tr> -
Peter Mescalchin created this gist
Apr 1, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,124 @@ # Bash if expressions cheatsheet <table> <tr> <th colspan="2">String</th> </tr> <tr> <td>Is equal</td> <td><code>if [[ $VAR1 == $VAR2 ]]</code></td> </tr> <tr> <td>Is empty / zero length</td> <td><code>if [[ -z $VAR ]]</code></td> </tr> <tr> <td>Not empty / non-zero length</td> <td><code>if [[ -n $VAR ]]</code></td> </tr> <tr> <td>Less than (ASCII alpha)</td> <td><code>if [[ $VAR1 < $VAR2 ]]</code></td> </tr> <tr> <td>Greater than (ASCII alpha)</td> <td><code>if [[ $VAR1 > $VAR2 ]]</code></td> </tr> <tr> <td>Regular expression</td> <td><code>if [[ $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <td>Regular expression not</td> <td><code>if [[ ! $VAR =~ ^my.+regexp$ ]]</code></td> </tr> <tr> <th colspan="2">Integer</th> </tr> <tr> <td>Is equal</td> <td><code>if [[ $VAR1 -eq $VAR2 ]]</code></td> </tr> <tr> <td>Not equal</td> <td><code>if [[ $VAR1 -ne $VAR2 ]]</code></td> </tr> <tr> <td>Less than</td> <td><code>if [[ $VAR1 -lt $VAR2 ]]</code></td> </tr> <tr> <td>Less than or equal</td> <td><code>if [[ $VAR1 -le $VAR2 ]]</code></td> </tr> <tr> <td>Greater than</td> <td><code>if [[ $VAR1 -gt $VAR2 ]]</code></td> </tr> <tr> <td>Greater than or equal</td> <td><code>if [[ $VAR1 -ge $VAR2 ]]</code></td> </tr> <tr> <th colspan="2">File system</th> </tr> <tr> <td>Is file (file, dir, symlink, anything)</td> <td><code>if [[ -e "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is regular file</td> <td><code>if [[ -f "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is regular file, is readable</td> <td><code>if [[ -r "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is regular file, is writable</td> <td><code>if [[ -w "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is regular file, is executable</td> <td><code>if [[ -x "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is directory</td> <td><code>if [[ -d "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is symlink</td> <td><code>if [[ -h "$FILEPATH" ]]</code></td> </tr> <tr> <td>Is socket</td> <td><code>if [[ -S "$FILEPATH" ]]</code></td> </tr> <tr> <th colspan="2">Combine expressions</th> </tr> <tr> <td>If EXPR1 and EXPR2 are true</td> <td><code>if [ (EXPR1) -a (EXPR2) ]</code></td> </tr> <tr> <td>If EXPR1 and EXPR2 are true</td> <td><code>if [[ (EXPR1) && (EXPR2) ]]</code></td> </tr> <tr> <td>If EXPR1 or EXPR2 are true</td> <td><code>if [ (EXPR1) -o (EXPR2) ]</code></td> </tr> <tr> <td>If EXPR1 or EXPR2 are true</td> <td><code>if [[ (EXPR1) || (EXPR2) ]]</code></td> </tr> </table> ## Reference - Most lifted from here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html. - Difference between `if [` and `if [[` tests: http://mywiki.wooledge.org/BashFAQ/031. - GNU Bash reference manual: http://www.gnu.org/software/bash/manual/bashref.html.