Extract Email Address

The file abc.af looks like this:

R1211566974^M
F<fettle@333empire.com>^M
T<gwensadler@vp.dk>^M

The following extracts the two email addresses:

cat abc.af |perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}'
fettle@333empire.com
gwensadler@vp.dk

Making a list one line

If you have a list in a textfile:

abd
def
ghi

You want to make into:

abc def ghi

Do this:

cat /tmp/textfile |tr "\n" " " > /tmp/textfile.withoutnewlines.txt

This command substitute newlines (ā€œ\nā€) with spaces (ā€ ā€) and send it to the file textfile.withoutnewlines.txt

Extract FQDN from URL

tdd@host:~/bin$ echo "http://domain.tdl/xx.?=0/ff" |awk -F '/' '{print $3}'
domain.tdl
tdd@host:~/bin$ 
 
indexes/regex-stuff-mail.txt · Last modified: 2010/02/03 11:51 by domingo
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki