Moving next 2 lines contents to previous lines

My input file is
aaa
bbb
ccc
a1a
b1b
c1c
a2a
b2b
c2c

I want the output file to look like that:
aaa,bbb,ccc
a1a,b1b,c1c
a2a,b2b,c2c

How do I achieve this ?

paste -d"," - - - file

Hi anbu23,

I tried ...but when I execute the paste command at shell prompt it gets stuck up for infinite time...and no outputs is created...

I am using the following :
home/myscripts > paste -d"," - - - a > b

Thanks

Try this

paste -d"," - - - <  a > b

a crude awk implementation

awk ' {     
              arr[NR] = $0","
              if (NR%3==0) { 
                     sub("," , "",arr[NR])                     
                     for (i in arr) printf arr 
                     print ""
                     delete arr
              }            
       }      
' "file"

Hello anbu23

It worked...thanks.

Amruta

That should be:

paste -d"," - - - < file

Or:

printf "%s,%s,%s\n" $( cat < file )

Which, in bash and ksh, can be shortened to:

printf "%s,%s,%s\n" $( < file )

Use paste -s to join subsequent lines, and use -d to supply the list of delimiters...

paste -s -d ',,\n' < file1 > file2

STATUS REPORT FOR JOB: Ftp
Generated: 2007-04-13 20:43:42
Job start time=2007-04-13 20:42:18
Job end time=2007-04-13 20:42:26
Job elapsed time=00:00:08
Job status=1 (Finished OK)

Hi i would like to insert the above report to database.

the column names in the table is:

1.Job start time
2.Job end time
3.Job elapsed time
4.Date

the corresponding timestamp has to be insert.

Date Column is from Job end time

How do i achieve this through Script?

Can anyone Please help me