bug-gnu-utils
[Top][All Lists]
Advanced

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

gawk


From: Vorst, Louis van der
Subject: gawk
Date: Fri, 16 Apr 2004 14:07:13 +0200

Hello

I try to use your gawk on the command prompt.

I build a script on unix, en there are no problems. I need the record
separator ^M.

The file is a HL7 communication protocol file. (The fields are separated
with a pipe sign and the different information blocks are divided by a cr
(for unix ^M, octaal 15)
I think it is not possible to use this recordsaperator in a dos box

My intention is to change two fields in a file

Can you advise me for solving my problem 

Thank you

Louis van der Vorst
06-22464782

Example of DOS layout
MSH|^~\&|gl|hl7|SN|hl7|19040413134608||ORU^R01|1415|P|2.3.1|||AL|NE
PID|1||19670224DIVS00||xxxxx||19670514|F||||||||||||||||N
Example of a part of a unix layout display:      |||N^MPV1|1|O
PV1|1|O
ORC|RE||L-00211||CM||^^^19011105072290^^R||19040413134608|||S.|I||||L
OBR|1||L-00211||||19011105072290|||||||19011106072290||S.||||||1904041313460
8||L|F||^^^^^R
OBX|1|ST|LS||05|||N|||F|||19011105072290|L|G
OBX|2|ST|LS||01|||N|||F|||19011105072290|L|G
OBX|3|ST|LS||2 |||N|||F|||19011105072290|L|G
OBX|4|ST|LS||35|||N|||F|||19011105072290|L|G
OBX|5|ST|LS||7 |||N|||F|||19011105072290|L|G

Example script with is workin correcrt in unix

BEGIN{RS="^M";ORS="^M";FS="|";d1="xxx";d2="yyy"}
{line=$0;
if(substr(line,1,3)=="PID"){
                a="";i=0;
                while (i < NF){++i;
                        if(i==6){a=a d1 "|"}
                        else{if(i==10){a=a d2 "|"}else{a=a $(i) "|"}}}
                        b=length(a);print substr(a,1,b-1)}else{print line}
}END{}










reply via email to

[Prev in Thread] Current Thread [Next in Thread]