When I try and use if [ "$1" =~ "$regex" ]; then
I keep on getting back the same error: [: =~: binary operator expected
Here is an example function where I get the error:
char_check() {
regex='^[]0-9a-zA-Z,!^`@{}=().;/~_|[-]*$'
if [ "$1" =~ "$regex" ]; then
echo "No illegal characters."
else
echo "Illegal characters."
fi
}
Any response would be a great help.