[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Sed script



Hi all,

>i need to extract the number 997841138254, or any other number from that
>position, from an hl7 file.  The file will look like this :
>
>MSH.......OBR|0001||997841138254|..........F
>
>I can use "OBR" as the starting point of the search and then use the "|" to
>move to the begginning of the number...

Ok here is an idea how to do it in awk.

awk -v FS="|" '{ if ( $1 ~ /OBR/ ) print $4; }'

Could ofcourse be made more advanced if the mumber of | preceeding ORB
is changing.

Runs on the command line or inside vim (vi).
In vim:
:%! awk -v FS="|" '{ if ( $1 ~ /OBR/ ) print $4; }'

Hope it helped

Best regards
Joakim


Reply to: