Difference between revisions of "Bash"
From John Freier
| Line 5: | Line 5: | ||
[[ 1 == 1 ]] && echo "text" | [[ 1 == 1 ]] && echo "text" | ||
| + | |||
| + | |||
| + | == Check for environment variable == | ||
| + | This will check to see if an variable is set | ||
| + | if [[ -z "$var" ]]; then | ||
| + | echo "var is not set" | ||
| + | fi | ||
Revision as of 15:26, 29 April 2021
One line conditional
Both the following lines will write to the screen "false"
[[ 1 == 0 ]] || echo "text"
[[ 1 == 1 ]] && echo "text"
Check for environment variable
This will check to see if an variable is set
if -z "$var" ; then echo "var is not set" fi