I am trying to selectively display several columns from a db2 query, which gives me a fixed-width output (partial output listed here):
--------- -------------------------- ------------ ------
000 0000000000198012 702 29
000 0000000000198013 29
000 702 29
000 0000000000198015 702 03
055 0000000000000001 702
I am trying to accomplish two things:
- parsing each field from each column, even the ones that are blank
- put a delimiter of ";" between each field
So expected output would be:
000;0000000000198012;702;29
000;0000000000198013;;29
000;;702;29
000;0000000000198015;702;03
055;0000000000000001;702;
This is my draft code, which works:
myquery | cut -c 1-9,11-48,60-68,112-142,143-159 --output-delimiter=";"
However my target system does not support any of the GNU utilities, so I cannot use the "output-delimiter" option with cut, or the "FIELDWIDTHS" option with gawk.
So how can I get the desired output, when there are blank fields in some columns?
Thanks in advance for your help!