Extract Domain Names From E-Mail Addresses
Hi
Just checking. What expression must I use if I want to extract domain names from a list of e-mail addresses? Any help will be appreciated. Kind Regards ARNOLD |
The format of the file would be the determining factor here. A simple cut statement may be all you need. Let us know the format so we can give you the best advice.
|
Hi Kustom42
Just normal e-mail addresses, like: abc@xyz.co.za jklmno.asdf@abc.org I want the result to be: xyz.co.za abc.org I hope it make sense Kind Regards ARNOLD |
Code:
cut -d@ -f2 ./filename.txt |
I guess I should explain whats happening, the old teach a man to fish thing.
The cut binary can be used to cut text out of a file or stream, you specify your delimter with -d, in this case you can use @, and you specify which field to cut with -f. So say for instance it was 1@2@3@4@5-6-7-8, - cut -d@ -f1 would give you just the number one. - cut -d- -f1 would give you just the number 5 - cut -d@ -f4 would give you the number 4 - cut -d- -f4 would give you the number 8 Cut by default will look for tabs as the delimter if you do not specify it with the -d option. |
Hi Kustom42
Thanks a million. By the way what does the -d and the -f2 mean. You also get a -f1 Kind Regards ARNOLD |
Looks like we were posting at the same time, check the above post and let me know if you have questions.
Bookmark www.ss64.com/bash/ as well. Good reference site for your more common commands. |
Brilliant
Thanks a lot. Much appreciated. |
All times are GMT -5. The time now is 11:08 AM. |