Differences between version 48 and predecessor to the previous major change of BashNotes.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 48 | Last edited on Tuesday, December 26, 2006 12:55:58 am | by BenStaz | Revert |
Older page: | version 43 | Last edited on Wednesday, December 6, 2006 1:29:24 am | by BenStaz | Revert |
@@ -357,11 +357,25 @@
*echo "scale=10;5/4" | bc"
will result in : 1.2500000000
The value of the scale function is the number of digits after the decimal point in the expression. (In this case 10)
+
+!How Can I use ''and'' / ''or'' in bash if statements?
+
+
+*You can do boolean OR in BASH by using the -o operator.
+*You can do boolean AND in BASH by using the -a operator.
+
+Try intermixing the two also.
+
+<verbatim>
+if [ $bla -eq 1 -o $cars -eq 3 -o $monkeys -eq 4 ]; then
+ echo "Westside"
+fi
+</verbatim>
!! See also
* CommonErrors, under "Your shell hangs"
* BashOneLiners
* SpacesInPathNames
* PortabilityNotes