I need to extract (or count) the lines (in a file) that have two or more dots. The lines should not start with dot (it’s OK if they end with a dot), and there must not be two dots in a row (i.e., the dots are all separated with non-dot characters).
Output Example:
a.b.
a.b.com
a.b.c.
a.b.c.com
But not:
a.com
a..b
a.b.c..d
I did this command:
grep -P '^[^.]+\.([^.]+\.)+[.]+' file.txt | wc -l
but it didn't find any matching lines. How should I do this?
[.]+
what I intend is to say followed b any character whether dot or other. The.
in RegEx refers to any character. Am I wrong? Can you clarify which part you are talking about? – user9371654 Apr 21 '19 at 20:09