I’m creating a shell script to a basic program.
One option is to delete a user, but the problem is that if I search for a string that belongs to the username in question, the program will assume it as a user aswell.
For example, if I have the user adminaaa if I search for admin the program will recognize it as a user, even if “admin” is not a user.
The piece of code that I’m using is the following:
existe=`cat meusutilizadores.txt|grep "$user" |wc -l`
if [ $existe = 1 ]
then
fullUser=`grep $user meusutilizadores.txt`
passUser=$(echo $fullUser|awk -F ':' '{ print $2 }')
What I need is to be able to program it to recognize the user for his entire string, not only a part of it.
I hope I was able to express myself well enough for you to understand.
Hope you can help me.
Best regards
Search for the whole term only:
egrep "^${user}$"This won’t work if
$usercontains regex special characters like[]().*+