Re: Join lines
- From: "John W. Krahn" <dummy@xxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 23:03:21 GMT
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
.........
$ echo "111
222
333
444
555
6666
77777
888
9999" | perl -lpe'$\ = eof() ? "\n" : $. % 3 ? "," : "\n,"'
111,222,333
,444,555,6666
,77777,888,9999
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- References:
- Join lines
- From: nickli2000
- Join lines
- Prev by Date: Re: FAQ 8.39 How do I set CPU limits?
- Next by Date: Re: SOAP::Lite
- Previous by thread: Re: Join lines
- Next by thread: Submit Your Perl Scripts
- Index(es):
Relevant Pages
|