I'm trying to make a bash script, validate a directory using regular expressions, what I have is the following.
echo "Ingresa La ruta de tu directorio"
read ruta
if [ $ruta != '^/[a-zA-Z]$' ];then
echo "No has ingresado una ruta valida, recuerda que la ruta inicia con /"
echo " "
continue
else
if [ -d $ruta ]; then
echo""
echo "hey, ya tienes creado tu directorio, tal vez necesites usar otra opcion"
continue
fi
fi
When I enter documents, the validation works, but when I enter, for example, /Documents
, which is an existing directory, the operation is the same and does not validate the expression, it is as if the /
will not be entered.
How could I validate the expression correctly?