I have the following in input.txt:
EA06\\?\.LFRFLB\\?\..*
I want to know if this pattern match with the following string:
EA06.LFRFLB.SHELLO
Then I coded:
MY_STRING="EA06.LFRFLB.SHELLO"
REGEX=$(cat input.txt) # EA06\\?\.LFRFLB\\?\..*
if [[ "${MY_STRING}" =~ "${REGEX}" ]]; then
echo "FOUND"
else
echo "NOT FOUND"
fi
if [[ "${MY_STRING}" =~ EA06\\?\.LFRFLB\\?\..* ]]; then
echo "FOUND"
else
echo "NOT FOUND"
fi
Result:
NOT FOUND
FOUND
Whats is going wrong here? Why the first if does not match correctly? What is the best way to solve it?
cat input.txt?