I am working a script to add a kind of sequence number as the third column to the data file, starting with a given number.
The data file uses pipeline "|" as the field delimiter.
1|AUGMENTIN 250-62.5 TAB CHEW F| |
2|AUGMENTIN XR 1,000-62.5 TAB F| |
3|AXERT 12.5 MG TABLET F| |
4|AXERT 6.25 MG TABLET F| |
5|AZMACORT INHALER F| |
B|BACTROBAN NASAL 2% OINTMENT F| |
7|BECONASE AQ 0.042% SPRAY F| |
8|BENICAR 20 MG TABLET F| |
9|BENICAR 40 MG TABLET F| |
A|BENICAR 5 MG TABLET F| |
I'd like the output shown as the follwoing:
start=5
1|AUGMENTIN 250-62.5 TAB CHEW F|F0005|
2|AUGMENTIN XR 1,000-62.5 TAB F|F0006|
3|AXERT 12.5 MG TABLET F|F0007|
4|AXERT 6.25 MG TABLET F|F0008|
5|AZMACORT INHALER F|F0009|
B|BACTROBAN NASAL 2% OINTMENT F|F0010|
7|BECONASE AQ 0.042% SPRAY F|F0011|
8|BENICAR 20 MG TABLET F|F0011|
9|BENICAR 40 MG TABLET F|F0011|
A|BENICAR 5 MG TABLET F|F0011|
start=5
cat $data_file | awk '{print $1 "|" $2 "|"}' \
'{printf "F%04d|", ++start}' \
> $result_file
Of course, the above thought did't work out for me.
Any hints and help are greatly appreciated.
The data file uses pipeline "|" as the field delimiter.
1|AUGMENTIN 250-62.5 TAB CHEW F| |
2|AUGMENTIN XR 1,000-62.5 TAB F| |
3|AXERT 12.5 MG TABLET F| |
4|AXERT 6.25 MG TABLET F| |
5|AZMACORT INHALER F| |
B|BACTROBAN NASAL 2% OINTMENT F| |
7|BECONASE AQ 0.042% SPRAY F| |
8|BENICAR 20 MG TABLET F| |
9|BENICAR 40 MG TABLET F| |
A|BENICAR 5 MG TABLET F| |
I'd like the output shown as the follwoing:
start=5
1|AUGMENTIN 250-62.5 TAB CHEW F|F0005|
2|AUGMENTIN XR 1,000-62.5 TAB F|F0006|
3|AXERT 12.5 MG TABLET F|F0007|
4|AXERT 6.25 MG TABLET F|F0008|
5|AZMACORT INHALER F|F0009|
B|BACTROBAN NASAL 2% OINTMENT F|F0010|
7|BECONASE AQ 0.042% SPRAY F|F0011|
8|BENICAR 20 MG TABLET F|F0011|
9|BENICAR 40 MG TABLET F|F0011|
A|BENICAR 5 MG TABLET F|F0011|
start=5
cat $data_file | awk '{print $1 "|" $2 "|"}' \
'{printf "F%04d|", ++start}' \
> $result_file
Of course, the above thought did't work out for me.
Any hints and help are greatly appreciated.