User Tools

Site Tools


howtos:regex-stuff-mail

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

howtos:regex-stuff-mail [25/08/2017 13:34] – created domingohowtos:regex-stuff-mail [02/12/2018 21:34] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +===== Extract Email Address =====
 +The file abc.af looks like this:
 +<file>
 +R1211566974^M
 +F<fettle@333empire.com>^M
 +T<gwensadler@vp.dk>^M
 +</file>
 +
 +The following extracts the two email addresses:
 +
 +<code>
 +cat abc.af |perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}'
 +fettle@333empire.com
 +gwensadler@vp.dk
 +</code>
 +
 +===== Making a list one line =====
 +If you have a list in a textfile:
 +<file>
 +abd
 +def
 +ghi
 +</file>
 +
 +You want to make into:
 +<file>
 +abc def ghi
 +</file>
 +
 +Do this:
 +<code>
 +cat /tmp/textfile |tr "\n" " " > /tmp/textfile.withoutnewlines.txt
 +</code>
 +
 +This command substitute newlines ("\n") with spaces (" ") and send it to the file textfile.withoutnewlines.txt
 +
 +
 +===== Extract FQDN from URL =====
 +
 +<code>
 +tdd@host:~/bin$ echo "http://domain.tdl/xx.?=0/ff" |awk -F '/' '{print $3}'
 +domain.tdl
 +tdd@host:~/bin$ 
 +</code>
 +
  
howtos/regex-stuff-mail.txt · Last modified: 02/12/2018 21:34 by 127.0.0.1