Why isn't this regular expression test working?<>
This question already has an answer here:
- bash regex with quotes? 4 answers
The problem is that you are using quotes...
In bash regex, there is no need for quotes, and moreso, they should not be used (unless you are trying to match a quote (in which case you can escape it \")... Also if you want a space in your pattern, you must escape it, \ (there is a space after the back-slash ...
Also note, that to match the entire line as being alphabetic, you must add a leading ^ and a trailing $, otherwise it will match such lines as: 123 456 abc. cat and mouse
if [[ $line =~ [a-zA-Z]+\. ]] ; then echo hello; fi
Some version of OS with bash gives you the output. So its up to you to get your updates. However, without regex you can use extended globbing
shopt -s extglob case "$line" in +([a-zA-Z]). ) echo "hello";; esac
if not, use regex without the quotes