I'm trying to use regext to detect if a string starts with a specific pattern or not but it does not work with me:
#!/bin/bash
line="{{ - hello dear - }}"
if [[ "${line}" =~ ^\{\{\s*-\s*hello\s*.*\}\} ]]; then
echo "got it "
fi
In this example, I expect the if condition to detect that the line variable has a string that starts with "{{ - hello" and ends with "}}" However, it does not do so as the echo message is not printed!
\sescape sequence.