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