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