[PLUG] edit lines in a text file

Steve Bonds 1s7k8uhcd001 at sneakemail.com
Tue Mar 29 19:52:44 UTC 2005


On Tue, 29 Mar 2005 11:36:33 -0800, Maodhog wrote:

> I want to take a text file, made up of email addresses and chop the
> users name off the domain name so I can uniq -u the domains.
> 
> I can't remember what the command is to remove all before the character
> "X"(which in this case is the @ sign).

awk -F@ '{print $2}' < your_file

or...

perl -p -e 's/^[^\@]+\@//' < your_file

or...

perl -n -e 'chomp; if (/\@(.*)$/) { print "$1\n" }' < your_file

And so on.  ;-)  Each responds slightly differently to malformed
input, so choose and adjust as is appropriate for the mangled files
you're likely to see.

  -- Steve



More information about the PLUG mailing list