Matching a domain with grep
Hi,
I need help matching a domain with grep. I have mydomains.txt which contains DNS1=mydomain.com DNS2=mydomain.net DNS3=mydomain.org DNS4=sub.mydomain.com and when I run cat mydomains.txt |grep expression I want it to match the top level domains only (not the subdomains) What would the correct expression for this be? I tried: cat mydomains.txt |grep ^DNS[1-9]=[a-z]\. but that matches the subdomain too and I tried: cat mydomains.txt |grep ^DNS[1-9]=[a-z]\.[com|net|org] which doesnt match any and cat mydomains.txt |grep ^DNS[1-9]=[a-z]\.[a-z]* which matches all and |grep ^DNS[1-9]=[a-z]\.[a-z^\.]* which matches all and |grep ^DNS[1-9]=[a-z]\.[a-z^\.]+ which matches none How can I get it to match all but the subdomain? TIA! |
Quote:
Code:
grep "^DNS[1-9]=[a-z]\+\.[a-z]\+$" mydomains.txt |
Thanks that worked.
|
All times are GMT -5. The time now is 04:36 AM. |