in reply to How to get a value from a file and save in another file

How (not) to ask a question
  • Comment on Re: How to get a value from a file and save in another file

Replies are listed 'Best First'.
Re^2: How to get a value from a file and save in another file
by Anonymous Monk on Apr 27, 2005 at 16:38 UTC
    Sorry for the cofusions and thanks for the help. I am new here I was not sure how to use the format yet. I am tring to output the first value with "LA" of each record.
    The data file should be:
    Record1: LA-1-00
    Record2: CON-1-0
    ------------LA-2-01
    Record3: LA-03-2
    ------------LA-03-02

    I need the output like:
    LA-1-00
    LA-2-01
    LA-03-2

      perl -nl -e '/^Record/../LA/ && /(LA.+)/ && print $1' datafile ?

      I'm sure I'm doing much more work than necessary - but it's hot in the office.

        Shorter:
        perl -nle '/^\d/ .. /(LA.*)/ && print $1' datafile

        Safer:
        perl -nle '/^\d/ .. /^\d*\s+(LA.*)/ && print $1' datafile