So, to run my script I use a parameter like this:
./script 789
The parameter is to change the permissions of a file or a directory, and I'd like to check if every digit is between 0 and 7, so what I tried is the next thing:
if [[ ${1:0:1} -ge 0 && ${1:0:1} -le 7 ]] && [[ ${1:1:1} -ge 0 && ${1:1:1} -le 7]] && [[ ${1:2:1} -ge 0 && ${1:2:1} -le 7]]
then {go ahead with the code}
else
echo "Error: each digit in the parameter must be between 0 and 7"
fi
If it's true, then go ahead with the script, else show an error message, but it doesn't seem to work.
[0-7][0-7][0-7]