07:38:36 EST
date 20041117
07:39:06 EST
07:00:29 EDT
date 20050504
07:25:16 EDT
07:00:40 EDT
date 20050505
07:23:12 EDT
I need to delete the new line character from all lines except 3rd,6th,9th etc. lines so that i get the output as below :
07:38:36 EST date 20041117 07:39:06 EST
07:00:29 EDT date 20050504 07:25:16 EDT
07:00:40 EDT date 20050505 07:23:12 EDT
How can I achieve this ?? I tried some combinations of sed which I know but no success ...... for eg: sed 'N;s/\n/ /' can join pairs of lines ... but not 3 lines at a time .. I am searching for some kind of one liner like that .. not a script ..
[/tmp]$ echo "07:38:36 EST
date 20041117
07:39:06 EST
07:00:29 EDT
date 20050504
07:25:16 EDT
07:00:40 EDT
date 20050505
07:23:12 EDT
" | sed -e 'N;N;s/\n/ /g'
07:38:36 EST date 20041117 07:39:06 EST
07:00:29 EDT date 20050504 07:25:16 EDT
07:00:40 EDT date 20050505 07:23:12 EDT