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

if i get your comment right, this could be:
c:\> perl -n -e "print $last, $_ if /xyzdf$/ && $last; $last= /^xyzdf +/ ? $_ : ''" file1>file2
Assuming file1 looks like
abc xyzdf def hij xyzdf klm xyzdf nop qrs xyzdf
file2 will end up as
xyzdf def hij xyzdf xyzdf nop qrs xyzdf
Is that what you want?

Update:
if not, post some sample data and the desired output.

Replies are listed 'Best First'.
Re^5: looking for speed!! large file search and extract
by smbs (Acolyte) on Jan 13, 2005 at 09:39 UTC
    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
      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