Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
echo "Enter username"
read $WORD

if [[ "$WORD" =~ ^(Dale|Paul|Ray)$ ]]; then
    echo "$WORD is valid"
else
    echo "$WORD is invalid"
fi
share|improve this question
    
I did format it like that, for some reason when I typed it here it changed. But it still doesn't work. – Maria C 18 hours ago
up vote 6 down vote accepted

The error is in read command, use read WORD instead of read $WORD.

Check this:

echo "Enter username"
read WORD

if [[ "$WORD" =~ ^(Dale|Paul|Ray)$ ]]; then
    echo "$WORD is valid"
else
    echo "$WORD is invalid"
fi
share|improve this answer
1  
It works!!! Thank you! – Maria C 18 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.