Re: Join lines
- From: Mirco Wahab <wahab@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 19:16:15 +0200
nickli2000@xxxxxxxxx wrote:
I have a file with a lot of lines with a singer number like the
following:
111
222
333
444
555
6666
77777
888
9999
..........
How could I join 3 lines at a time and with a "," in between and at
the beginning of the next line, as in the following:
111,222,333
,444,555,6666
,77777,888,9999
Is this Unix/Linux? Then do a simple:
perl -0777 -pe 's/\n/(++$n%3)?",":"\n,"/eg' lines.txt > commas.txt
if your file is 'lines.txt'.
In Win32, you have to change the quotes.
Regards
M.
.
- Follow-Ups:
- Re: Join lines
- From: nickli2000
- Re: Join lines
- References:
- Join lines
- From: nickli2000
- Join lines
- Prev by Date: Re: Symrefs
- Next by Date: Re: Symrefs
- Previous by thread: Re: Join lines
- Next by thread: Re: Join lines
- Index(es):