yes, exactly
|
Code:
awk 'BEGIN { FS="|" } { if (NF == 13) print $0"|"; else print; }' |
these were the original lines:
MSH| ~\&|ANTRIM|blah blah blah 33D0654120 CLIA|CDR|LMS|201009180440||ORU R01||D|2.3.1| PID|1||0386132|0386132|Donald Duck ||19570210|M|U|| when i run the awk code i get this: MSH| ~\&|ANTRIM|blah blah blah 33D0654120 CLIA|CDR|LMS|201009180440||ORU R01||D|2.3.1|| PID|1||0386132|0386132|Donald Duck||19570210|M|U|| it looks like its adding it to the line that starts with MSH instead |
Change the code to:
Code:
awk 'BEGIN{ FS="|" } $1~/PID/ {if(NF == 13) print $0"|"; else print; }' |
Code:
awk -F"|" '/^PID/ && NF <= 13{$13=OFS="|"}1' file |
All times are GMT -5. The time now is 11:25 AM. |