Link to home
Start Free TrialLog in
Avatar of md168
md168

asked on

grep for a string with a .

I'm grepping for spam URLs.  I created a test file.  I want to find ".ru/"

# cat file.txt
file.ru/
fileru/

# grep --regexp="[A-Za-z0-9].ru/" file.txt
file.ru/
fileru/
# grep  -e ".ru/" file.txt
file.ru/
fileru/

How do I get grep to look for the period in ".ru/"?  
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

grep -e \.ru file.txt
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HonorGod
Remember that in Regular Expressions, a dot (period) is a meta-character to match "any character".
Whenever you want to match a real character that happens to be a meta-character, you have to escape that meta-character by preceding it with a backslash.

Hopefully this helps