?
Solved

How to add a comma at the end of each line?

Posted on 2009-12-17
4
Medium Priority
?
565 Views
Last Modified: 2013-11-17
Hi,

  I have a text like below in vi editor.As you can see, not all lines are ending with a comma.
 I need to add comma to the end of each line globally. How can i achieve this?
a,b,c,
d,e,f,
g,h,i
j,k,l
m,n,o,
p,q,r
s,t,u,
v,w,x
y,z
0
Comment
Question by:pvsbandi
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
wrmichael earned 500 total points
ID: 26074313
:1,$s/$/,/g
0
 

Author Comment

by:pvsbandi
ID: 26074429
Thanks! Works..but it is adding an additional comma for the lines which has a comma already
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 500 total points
ID: 26074439
To avoid ",," at the end

:1,$s/,$//
:1,$s/$/,/

wmp
0
 

Author Comment

by:pvsbandi
ID: 26074568
Perfect!!  Thanks both!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question