Inserting a comma "," in the end of every line ( no matter what ).

Inserting a comma "," in the end of every line ( no matter what ).

Post by Admi » Wed, 17 Jul 2002 11:56:05



Dear all,
What could be the easiest way of adding a comma "," at the end of every line.
No matter if the file may also contain blank lines.
e.g.
John Dow,
123 Address Road,
,
,
Washington,
DC,
11223,
,

Thanks in advance.

 
 
 

Inserting a comma "," in the end of every line ( no matter what ).

Post by Andreas K?h? » Wed, 17 Jul 2002 12:29:03


Submitted by "Admin" to comp.unix.shell:

Quote:> Dear all,
> What could be the easiest way of adding a comma "," at the end of every line.
> No matter if the file may also contain blank lines.
> e.g.
> John Dow,
> 123 Address Road,
> ,
> ,
> Washington,
> DC,
> 11223,
> ,

> Thanks in advance.

perl -pe 's/$/,/' < oldtext > newtext

--
Andreas K?h?ri
--------------------------------------------------------------
Stable, secure, clean, free:  www.netbsd.org

 
 
 

Inserting a comma "," in the end of every line ( no matter what ).

Post by William Par » Wed, 17 Jul 2002 13:50:15



> Dear all,
> What could be the easiest way of adding a comma "," at the end of every line.
> No matter if the file may also contain blank lines.
> e.g.
> John Dow,
> 123 Address Road,
> ,
> ,
> Washington,
> DC,
> 11223,
> ,

> Thanks in advance.

sed 's/$/,/'

--

8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin

 
 
 

Inserting a comma "," in the end of every line ( no matter what ).

Post by Cameron Simpso » Wed, 17 Jul 2002 14:02:38



| Submitted by "Admin" to comp.unix.shell:
| > Dear all,
| > What could be the easiest way of adding a comma "," at the end of every line.
| > No matter if the file may also contain blank lines.
| > e.g.
| > John Dow,
| > 123 Address Road,
| > ,
| > ,
| > Washington,
| > DC,
| > 11223,
| > ,
|
| perl -pe 's/$/,/' < oldtext > newtext

sed 's/$/,/' < oldtext > newtext

Shorter and simpler. Perl overuse is the bane of modern systems. Well, a
bane, anyway.
--

Zenophobia: the irrational fear of convergent sequences.

 
 
 

Inserting a comma "," in the end of every line ( no matter what ).

Post by Tho Nguy » Wed, 17 Jul 2002 15:36:35



> Dear all,
> What could be the easiest way of adding a comma "," at the end of every line.
> No matter if the file may also contain blank lines.
> e.g.
> John Dow,
> 123 Address Road,
> ,
> ,
> Washington,
> DC,
> 11223,
> ,

> Thanks in advance.

sed 's/$/,/' yourfile