Regular expression used for letters not failing for dots

while read first last email
#echo "$first" "$last" "$email"
if [[ "$first" =~ $re && "$last" =~ $re ]]; then
        echo "$email"
        echo "bad"
done < "$filename"

I am writing a bash script and trying to check the format list provided in the argument of the shell filename.File has the content as

Noble Able
Bob builder <>
Chris Charley
Ed Edwards Kola Jones

As what I expect it should give error(print bad) at the last line since it has the dot character but my result is


Regular expressions in the =~ construct are not anchored (unlike patterns which might have confused you: [[ $first == +([a-zA-Z]) ]]).

Regex matches even if a substring of the string matches it. You need to use ^ and $ for the beginning and end of the string, respectively.

[[ $first =~ ^[a-zA-Z]+$ ]]

Need Your Help

Is there a good way to deal with form submission in Scalatra

scala scalatra

Right now I'm just using params function to get the data that has been posted to an URL.

Android NDK: Multiple definition of .o and .c files

android c++ android-studio android-ndk java-native-interface

i want to implement a library with java and native code in my app project in Android Studio. Everytime when I change the c++ code, I have to recompile the c++ files so that the changes take effect ...