I need to compare a variable to some string (and do something if they match).
if [ "$x" == "valid" ]; then echo "x has the value 'valid'" fi
If you want to do something when they don't match, replace
!=. You want the quotes around
$x, because if
$x is empty, you'll get
if [ == "valid" ]... which is a syntax error.