[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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