I have a file with content similar to:
mail.google.com
srv1.mail.google.com
google.com
facebook.com
yahoo.com
tt.twitter.com
I want to search for lines with subdomains. I used this command:
grep -e '(.\.)*.\..$' test.txt
The command details:
(.\.)*
: for any characters followed by dot one or more times..\..$
: anycharacter followed by dot, then any character
Examples of the string patterns I expect to find:
mail.google.com
srv1.mail.google.com
but it does not find anything. The output I am looking for should be lines with subdomains:
mail.google.com
srv1.mail.google.com
tt.twitter.com