|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a bunch of email addresses abc@yahoo.com defgh@google.com I just want to keep the domains and strip of the name: like: yahoo.com google.com |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-11-7, 13:34(-08), rogv24@yahoo.com:
> > I have a bunch of email addresses > > abc@yahoo.com > defgh@google.com > > I just want to keep the domains and strip of the name: > like: yahoo.com > google.com cut -d@ -f2- << EOF abc@yahoo.com defgh@google.com EOF -- Stéphane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2006-11-07, rogv24@yahoo.com wrote:
> > I have a bunch of email addresses > > abc@yahoo.com > defgh@google.com > > I just want to keep the domains and strip of the name: > like: yahoo.com > google.com How do you "have" them? If they are in variables, use parameter expansion: email=abc@yahoo.com domain=${email#*@} If they are in a file, use cut: cut -d@ -f2 FILE Or, if you need to manipulate the domains after extracting them: while IFS=@ read a domain do ## DO something with $domain here done < FILE Or: awk -F@ '{ domain=$2 # do something with domain here }' FILE -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Thank you
Stephane CHAZELAS wrote: > 2006-11-7, 13:34(-08), rogv24@yahoo.com: > > > > I have a bunch of email addresses > > > > abc@yahoo.com > > defgh@google.com > > > > I just want to keep the domains and strip of the name: > > like: yahoo.com > > google.com > > cut -d@ -f2- << EOF > abc@yahoo.com > defgh@google.com > EOF > > -- > Stéphane |
|
![]() |
| Outils de la discussion | |
|
|