How to generate a csv files by separating the values from the input file based on position?

Hi All,

I need help for doing the following.
I have a input file like:

aaaaaaaaaabbbbbbbbbbbbbbbbbbbb
cccbbbbbaaaaaadddddaaaabbbbbbb

now I am trying to generate a output csv file where i will have for e.g.
0-3 chars of each line as the first column in the csv, 4-10 chars of the line as the second column of the csv.

What about rest of the characters 11-...? Should they be in 3rd column?

Something like

$ sed 's/^\(...\)\(.......\)/\1;\2;/g' infile
aaa;aaaaaaa;bbbbbbbbbbbbbbbbbbbb
ccc;bbbbbaa;aaaadddddaaaabbbbbbb
$ sed 's/^\(...\)\(.......\).*/\1;\2;/g' infile
aaa;aaaaaaa;
ccc;bbbbbaa;

?

1 Like

guys thanks for the replies...I think the first e.g. of sed will be helpful..................