I don’t how to use regex properly in bash, i got an error trying to do in this way, what is wrong in that regex verification?
#!/bin/bash
if [ ! $# -eq 1 ]; then
echo "Error: wrong parameters"
else
if [ $1 =~ "[a-z]" ]; then
echo "$1: word"
elif [ $1 =~ "[0-9]" ]; then
echo "$1: number"
else
echo "$1: invalid parameter"
fi
fi
I have reworked your script and get the expected result with the following:
You do not need to quote your Regex.