Table of Contents

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$