Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2010
    Location
    North Brunswick, NJ
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need some help on an AIX command to replace characters in a file but not all the characters.
    I have a file with this as sample data "MSH|data||other data|more stuff||~PV1|stuff|||PV2|||^12345 3456 help me here|||"

    I'm trying to find the PV2 section and replace the spaces in the section following the ^. I want to replace those spaces with ^ until the next pipe character.

    Any ideas? I've been trying awk but I'm not sure how to get to the PV2 section that I want to work with.

    Thanks.
    Tom

  2. #2
    New Lounger
    Join Date
    Jan 2010
    Location
    North Brunswick, NJ
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've had a few views on this message but no answers. If anyone's interested, I got the answer.

    Using awk I can find the PV2 segment and replace spaces in $4 (the fourth field) with ~ and then I can treat it as sub fields of the field. Actually it's sub fields of the sub field since the first character is a ^.

    The code snippet looks like this:
    { if ($1 == "PV2")
    gsub( " ", "~", $4 )
    }
    There's more around it for writing it out after changing the field but this is the part I was looking for. Maybe it can help someone else, maybe not.

    Tom

  3. #3
    New Lounger
    Join Date
    Oct 2010
    Location
    Kansas
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by TomCanavan View Post
    I've had a few views on this message but no answers. If anyone's interested, I got the answer.

    Using awk I can find the PV2 segment and replace spaces in $4 (the fourth field) with ~ and then I can treat it as sub fields of the field. Actually it's sub fields of the sub field since the first character is a ^.

    The code snippet looks like this:
    { if ($1 == "PV2")
    gsub( " ", "~", $4 )
    }
    There's more around it for writing it out after changing the field but this is the part I was looking for. Maybe it can help someone else, maybe not.

    Tom

    Are you having a lot of trouble with your HL7 messages?

    Scott

Posting Permissions

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