jeudi 27 juillet 2017

Bash: shell script if statement using multiple conditions including regex

I am currently studying the shell script and having some syntax issue.

what I am tyring is to make the 'if' statement to catch any user-input with alphabet, except the "giveup" line

here is the code that I built:

if [ $usrGuess =~ *[:alpha:]* && $usrGuess != "giveup" ]

once I run the code, it gives out the error message saying that:

[: missing `]'

If you guys have any solution to this, I will be happy to hear your advice :)

Thanks!

Aucun commentaire:

Enregistrer un commentaire