splitting a huge line of file into multiple lines with fixed number of columns

Hi,

I have a huge file with a single line.
But I want to break that line into lines of with each line having five columns.
My file is like this:
code:
"hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","you."

I want it like this:
code:
"hi","there","how","are","you?"
"It","was","great","working","with"
"you.","hope","to","work","you"

I found the following link..but was not of much help.

It breaks the line the basis of number of characters in the lines.

In my case, the length of each column values is different.
My OS is AIX 5.3 with ksh

Anybody having an idea as how this cud be done?
Thanks
raj.

Hi,

A solution using Perl:

$ cat infile
"hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","y ou."
$ perl -ne 's/,/++$i % 5 ? "," : "\n"/ge; print' infile
"hi","there","how","are","you?"
"It","was","great","working","with"
"you.","hope","to","work","y ou."

Regards,
Birei

1 Like