I have a txt file , email.txt, full of data in the following format and I basically want to extract all the email addresses.
Code:
jjlkgfjlk
dfkf;k;fkf
<user1@email.com>
kkdsks
ffp;fd;d
<user2@email.com>
dsk;k;kl;dkd
The one-liner I use is :
Code:
uncle-c@home:~/Perl/$ perl -ne '/^<(.*)>/ && print $1 ' email.txt
user1@email.comuser2@email.comuncle-c@home:~/Perl/$
What looks obvious here is that output of each regex capture needs to be put on a new line for clarity. I've tried alterations along the lines of print $1\n etc but I'm not getting anywhere. Prob something very simple and obvious so apologies for my ignorance :-)
What would really help would be what I am doing wrong and and an explanation of the solution. I am just starting off learning Perl ( self taught) so any input is very very useful.
Thanks.