how to extract multi-line text

Discussion in 'Perl Misc' started by perltcl@yahoo.com, Jul 19, 2006.

  1. Guest

    hi

    how to extract multi-line text from a text file looking like this:
    #!/bin/bash

    ....

    BEGIN_TOKEN
    multi-line text 1
    .......
    .......
    END_TOKEN

    BEGIN_TOKEN
    multi-line text 2
    .......
    .......
    END_TOKEN

    BEGIN_TOKEN
    multi-line text 3
    .......
    .......
    END_TOKEN

    I need to extract all text between "BEGIN_TOKEN" and "END_TOKEN", and
    pipe it to standard output.

    thanks.
     
    , Jul 19, 2006
    #1
    1. Advertising

  2. AbhiSawa Guest

    wrote:
    > hi
    >
    > how to extract multi-line text from a text file looking like this:
    > #!/bin/bash
    >
    > ...
    >
    > BEGIN_TOKEN
    > multi-line text 1
    > ......
    > ......
    > END_TOKEN
    >
    > BEGIN_TOKEN
    > multi-line text 2
    > ......
    > ......
    > END_TOKEN
    >
    > BEGIN_TOKEN
    > multi-line text 3
    > ......
    > ......
    > END_TOKEN
    >
    > I need to extract all text between "BEGIN_TOKEN" and "END_TOKEN", and
    > pipe it to standard output.
    >
    > thanks.



    One more small fish

    perl -ne 'print if /^BEGIN_TOKEN$/ .. /^END_TOKEN$/' filename


    AbhiSawa
     
    AbhiSawa, Jul 19, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prabh
    Replies:
    1
    Views:
    461
    Marco Schmidt
    Sep 1, 2003
  2. dean
    Replies:
    5
    Views:
    481
    Phlip
    Jun 4, 2006
  3. kaushikshome
    Replies:
    4
    Views:
    796
    kaushikshome
    Sep 10, 2006
  4. bernadou

    Force multi line field value to output with line breaks?

    bernadou, Jan 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    371
    bernadou
    Jan 23, 2006
  5. Replies:
    2
    Views:
    152
Loading...

Share This Page