I'm writing some very simple Bash scripts and I've become a tad bit stuck.
I would like the script I'm attempting to write to be able to differentiate between "non valid inputs ie letters" from "valid inputs ie numbers from a specific range"
Currently the script "works" although I'm having troubles with another echo that I would like only to "echo" when the below line is "not true", is there a simple way to write this? I'm not specifically looking for efficient code, just code that I can learn from and understand at my amateur level.
So, long story short, is it possible to obtain information from the command line below, so that I can have a simple "not true" variable that I can use in another "else" or "elif" command?
For reference line 1 is to detect alphabetical inputs, and line 2 being the line of code I would like to write as "not true" for use in another part of my script.
let xx=$a+1-1 2>/dev/null; ret=$?
if [ $a -ge 7 ] && [ $a -le 70 ] && [ $xx -eq $xx ] && [ $ret -eq 0 ]
[ .. ](there is no need in[[ .. ]]), but in[ .. ]it is mandatory. ([ .. ]is an alias fortest). To suppress the error when a non-integer is entered forxx, you can[ "$xx" -eq "$xx" 2>/dev/null ]to redirectstderrto/dev/null(the bit-bucket...):)along with shellcheck.net Spending a bit of time with the Advanced Bash-Scripting Guide is time well spent.bashtag under your question, then click "Learn more..." for the bash tag wiki here on stackoverflow.[[ $a == *[A-Za-z]* ]]. Checking whetheracontains any nun-numeric character can be done by[[ $a == *[^0-9]* ]].