bash
Bash : Compound condition using && (AND) and || (OR) operators
Submitted by khairie on Mon, 06/21/2010 - 17:47
To have compound conditions in bash using
&& or ||:-
if [ $VAR1 -eq 1 ] && [ "$VAR2" == "true" ] then # do something fi if [ "$VAR1" == "String 1" ] || [ "$VAR2" == "String 2" ] then # do something fi
Reference: http://www.museum.state.il.us/ismdepts/library/linuxguides/abs-guide/ops.html#ANDOR
- Add new comment
- 121 reads
Bash : Compare Strings With Spaces
Submitted by khairie on Tue, 06/15/2010 - 13:01
To compare two strings that contain spaces in bash, enclose them with a double quote (e.g. "$VAR" ). Example below:-
if [ "$VAR" == "this is a string with spaces" ] then # do something fi
Reference: http://hacktux.com/bash/string
- Add new comment
- 170 reads
Recent comments
14 weeks 5 days ago
1 year 4 days ago
1 year 4 weeks ago