Originally Posted by troop
if [[ "$test" =~ ^[A-Za-z] ]]; then
echo "Invalid input"
That did work. However, for sake of code cleanliness, I was hoping for the syntax to say: If the variable does not begin with a letter of the alphabet (regardless of capitalization), then display an error message and exit with status code 1. Is this possible?
The reason is because if I go with your code, this is how it would look:
if [[ "$interface" =~ ^[A-Za-z] ]]; then
echo "" >/dev/null
ERROR 7: No usable interface label detected.
Thank you for your reply. You gave much more information than my weak Googling skills gave me.