I had this in my temp file: abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com abc 123 53432 t...@gmail.com
Running the following command: perl -n -e 'm/.* ([^ ]+@.*)$/i; print $1."\n"' temp will print: t...@gmail.com t...@gmail.com t...@gmail.com t...@gmail.com t...@gmail.com You can also redirect the output into a file by: perl -n -e 'm/.* ([^ ]+@.*)$/i; print $1."\n"' temp > out -- Fruit Vendor On Sun, Jul 13, 2014 at 4:00 PM, Paul Johnson <p...@pjcj.net> wrote: > On Sun, Jul 13, 2014 at 04:43:41PM -0400, ESChamp wrote: > > I apologize for having to ask this but my nearly-80-year-old brain just > > could not come up with a solution. > > > > I have a text file consisting of several space-separated fields: > > > > lastname firstname other other other ... emailaddress > > > > I wish to write a new file that contains only the emailaddress field > > contents. > > > > There's no need to test the emailaddress field. > > > > I just need a quick and dirty solution as this will be used just one > time. > > Quick and dirty solution: > > $ perl -nale 'print $F[-1]' < original_file.txt > just_email.txt > > perldoc perlrun if you want to see why that works. Take a look at the > -a option. The -1 index into @F says use the last element of the array. > > -- > Paul Johnson - p...@pjcj.net > http://www.pjcj.net > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >