in reply to Re^2: Extracting specific Data
in thread Extracting specific Data

Okay what if I had a file from which i had to extract data between those two words. But dont want it to match globally. For instance the word1 and word2 appears the first time it prints the data between them, and word1 again appears somewhere in the file and word2 also appears again. So it is like chunks of data through the file between the ~"word1" and "word2".... Nothing happens when i remove the match global (mg) at the end of the specified words...

Replies are listed 'Best First'.
Re^4: Extracting specific Data
by Tux (Canon) on Jun 26, 2012 at 14:33 UTC

    And what are the requirements when regions overlap? And what if start/end words double?

    You should look into constructs like

    $ perl -ne'/start/i .. /end/i and print' file $ perl -ne'/\b start \b/ix ... /\b end \b/ix and print' file

    And start reading :)


    Enjoy, Have FUN! H.Merijn