Reputation: 73
I am looking to extract strings that have exactly 2 dots like below.
a.b.c
$$abc.$$def.123
The relevance is only to the dots.
So far i have tried
grep "\\.{2}" file_name.txt.
But this is not giving me the result. Could you please help me
Upvotes: 0
Views: 263
Reputation: 4540
I think this is just a regular expression issue. Your \.{2} will match two consecutive dots. What you'll probably want is something like:
^[^\.]*\.[^\.]*\.[^\.]*$
Which is "start of string, zero or more not-dots, a dot, zero or more not-dots, a dot, zero or more not-dots, end of string".
Upvotes: 1