Results 1 to 2 of 2

Thread: Piping options

  1. #1
    Join Date
    Nov 2003
    Location
    India
    Posts
    114

    Unanswered: Piping options

    Hi All

    This is my file format. In this format in the second line first 6 characters after the space are membership code.I want to extract this from the file for my validtaions. How can I do this in Unix?

    010640CAMPOPD01CMGBA 30092004163236 Y
    150058270 Z00604N17846
    114202062

    The part which i want to extract is Z00604.

    Plz help ?

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    Code:
    sed -n -e '2p' file.txt | sed -e 's/^[^ ][^ ]* \(......\).*/\1/'
    or with awk:
    Code:
    awk 'FNR==2 {print substr($2,1,6)}' file.txt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •