how to change row into columns

hi,
I have a input file like

a,123,456,789,012,.......,b

I need to change the output file into

a,123,b
a,456,b
a,789,b
a,012,b
a,...,b
like that..

how to achieve that through UNIX.................

check if this works for you..

tr ',' '\n' < input_file

it has not given my expectation. it gives the output like
a
123
456
789
012
b
a
123
456
789
012
b
a
123
456
789
012
b
a
123
456
789
012
b
a
123
456
789
012
b

please advice me..

tr is hardly the command to use here.

awk -F, '{ first=$1; last=$NF; for (i=2; i<NF; ++i) print first "," $i "," last }' input_file

Thanks a lot ERA...... :smiley:

if you have PHP

<?php
$filename="file";
$data = split(",",file_get_contents($filename));
$chunk=array_chunk($data,3,TRUE);
foreach (  $chunk as $a){
 echo implode(",",$a) ."\n";
}
?>

output:

# more file
a,123,456,789,012,abc,def,b
# php test.php
a,123,456
789,012,abc
def,b