in reply to Re^4: looking for speed!! large file search and extract
in thread looking for speed!! large file search and extract

Thanx but not what I would like
Input file

xyzdfhhlhlljjlxyzdf
PARTNAMEhjjhhjhjkjkjkjkjPARTNAME
hjill''';
hgkjlklj
xyzdfhhlhll666666jlxyzdf
PARTNAMEhjjh88888888888jkjkjkjkjPARTNAME
xyzdfh
PARTNAMEh_not_to_be_extracted_jkjkjkjPARTNAME
ghghjhj
jlkjpkj
xyzdfhhlh888888888ljjlxyzdf
PARTNAMEhjjh8888iiiiiiiiiiiii888jkjkjkjkjPARTNAME

Output file

PARTNAMEhjjhhjhjkjkjkjkjPARTNAME
PARTNAMEhjjh88888888888jkjkjkjkjPARTNAME
PARTNAMEhjjh8888iiiiiiiiiiiii888jkjkjkjkjPARTNAME

only 3 lines extracted because line above condition not
meet
  • Comment on Re^5: looking for speed!! large file search and extract

Replies are listed 'Best First'.
Re^6: looking for speed!! large file search and extract
by holli (Abbot) on Jan 13, 2005 at 10:14 UTC
    c:\> perl -n -e "print if /^PARTNAME/ && /PARTNAME$/ && $last; $last = + /^xyzdf/ && /xyzdf$/ ? $_ : ''" file1>file2 # file2: #PARTNAMEhjjhhjhjkjkjkjkjPARTNAME #PARTNAMEhjjh88888888888jkjkjkjkjPARTNAME #PARTNAMEhjjh8888iiiiiiiiiiiii888jkjkjkjkjPARTNAME
    Update: This will also match lines like:
    xyzdf PARTNAMEXXXXPARTNAME
    if that is unwanted you should use:
    c:\> perl -n -e "print if /^PARTNAME/ && /PARTNAME$/ && $last; $last = + /^xyzdf/ && /.xyzdf$/ ? $_ : ''" file1>file2