In a bash script I have a function, in which I want to check if the passed argument contains only lowercase letters, numbers and "_":
Also to check not to be only numbers and start only with a letter
The code:
function check_name () {
 if [[ $1 != [a-z0-9\\_]; then
    echo The name can contain only lowercase letters, numbers and _
    return 1
 fi
}
The code fails, because always the condition is true and returns 1
 
    