Is it possible to setup two conditions for an if then statement in a pbash script?
For example, depending on the text value of a variable I parse out of an xml file, I want to assign it a numerical values.
Example:
if [ "$VAR" = "Upper" ]; then
VAR="25"
fi
if [ "$VAR" = "Lower" ]; then
VAR="25"
fi
Can these two statements be replaced with a single one?
if [ "$VAR" = "Upper" -o "$VAR" = "Lower" ]
VAR="25"
fi
here -o represents logical or
era
3
What's "pbash"?
if [ "$VAR" = "Upper" ] || [ "$VAR" = "Lower" ]; then
VAR=25
fi
Modern POSIX shells have a richer set of conditionals using [[ conditions ]], or you can use case:
case $VAR in Upper|Lower) VAR=25;; esac
Typeo... just plain bash
Thanks as always for the great replies. These forums and the contributing members are terrific!