regex with $ variablkes bash in a if statement code example Example: using regex in bash conditional statement pat="[0-9a-zA-Z ]" if [[ $x =~ $pat ]]; then ...