Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with grep and regular expresions 1

Status
Not open for further replies.

jmiturbe

Technical User
Feb 4, 2003
99
ES
Hello,

I`m trying to write a shell script that parses email addresses. The problem is that my script treates the dot on email addresses as a wilcard, so it matches more addresses than really needed.

Does anybody know how to avoid this? Thanks in advance.

jmiturbe
 
escape the metacharacter with a backslash?

\.


Kind Regards
Duncan
 
Hi:

I have the same (or similar) problem that jmiturbe. I have a script that asks for an email account and the user inputs it. If this user inserts a email account which has a dot it match more addreses than the really are.

Example:

#script
echo "User account:\c"
read codigo
grep -v ^${codigo} aliases > aliases.tmp; cp aliases.tmp aliases
#script
 
Have you tried this ?
read codigo
codigo=$(echo $codigo | sed -e 's!\.!\\.!g')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top