I have a file that used to contain two CSV columns but has had its commas removed so that each line is one full "record". I need to separate these into two records again by adding a comma, but the lines are between 20 to 21 characters and need to be processed accordingly - if the line is 20 characters the comma needs to be added at the 16th position, and if the line is 21 characters the comma needs to be added at the 17th position. If I've done my maths right this would result in a second column that has 5 characters on all lines.
What's the best way to accomplish this using Bash and GNU tools?
With sed:
sed -E 's/.{5}$/,&/' file