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