Hi All,
I need to convert a fixed length file to a delimited file with , (comma). But not all columns, some of the columns in the fixed files are used as fillers and I do not need that in the output file.
test_fixed_len.txt
I 0515 MR 394
I 0618 MR & MRS 942
I 0618 MR & MRS 944
I 0205 MR & MRS 614
I 0122 MR 940
The file is defined as
transaction type - 1 char
filler - 3 char
date - 4 char
filler - 1 char
name header - 8 char
filler 1
transaction number - 3 char
I need the input file converted into a delimited file like
I,0515,MR,394
I,0618,MR & MRS,942
I,0618,MR & MRS,944
I,0205,MR & MRS,614
I,0122,MR,940
Which is:
transaction type,date,name header,transaction number
with no fillers.
I tried:
sed -e 's/./&,/1' -e 's/./&,/9' -e 's/./&,/19' test_fixed_len.txt
This is adding , in the positions I want. I also need to remove the extra spaces in a column if there are any.
Can anyone help me if there is a better way?