Posted By

fugue on 04/03/12


Tagged

regex find


Versions (?)

Print any line matching the regular expression /foo/ in input.txt


 / Published in: Perl
 

URL: http://www.reddit.com/r/perl/comments/rr1gs/need_to_use_perl_e_to_search_for_string_and/c47y0au

-n means loop over the lines of all file names given on the command line, or standard input if none were given. -E is a version of -e that enables newer features like say, which is the same as print but adds a newline.

  1. perl -nE 's/\s+$//, say if /foo/' input.txt

Report this snippet  

You need to login to post a comment.