I am new to shell scripts.Can u please help me on this req.
test_user = "Arun"
if [ test_user == words] [Help me with reg.ex to check]
echo "test_user is a word"
else
echo "test_user is not a word"
I am new to shell scripts.Can u please help me on this req.
test_user = "Arun"
if [ test_user == words] [Help me with reg.ex to check]
echo "test_user is a word"
else
echo "test_user is not a word"
Your question is not clear - what is the regex supposed to check for? Do you want to see how many words are in the variables test_user?
words=$(echo "$test_user" | awk '{print $NF;next} ')
if [ $words -ne 1 ] ; then
echo 'bad input'
else
echo 'ok'
fi
This is one way. I did not use a regex, just awk.