• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

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/"?  
0
md168
Asked:
md168
  • 2
1 Solution
 
wesly_chenCommented:
grep -e \.ru file.txt
0
 
wesly_chenCommented:
Sorry, forget the double quote

grep -e "\.ru" file.txt
0
 
HonorGodSoftware EngineerCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now