[Omaha.pm] "grep" huge files w/ no linefeeds

Jay Hannah jhannah at omnihotels.com
Wed May 2 15:14:45 PDT 2007


Problem:

You have a 150MB file where "lines" of data are separated by the pipe
character, but there are no newlines (or carriage returns) anywhere in
the file. 

Find the "line" that contains the string 'MERGE-TO'. 

(grep will tell you that all 150MB of the file matches that string. Not
very helpful.)


Solution:

Tell Perl that your line delimiter is '|' and to print if a line
contains 'MERGE-TO'.

$ perl -nle 'BEGIN {$/="|"} print if (/MERGE-TO/)' myfile.txt
"AA","NMT","NO ""MERGE-TO"" ACCOUNT WAS FOUND","300"


:)

j


More information about the Omaha-pm mailing list