If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Shell script to add 3 commas at the end of each line of a file

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-08-09, 01:08
bakkiya bakkiya is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
Shell script to add 3 commas at the end of each line of a file

Can anyone please help me in writing Shell script to add 3 commas at the end of each line of a file.
Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-08-09, 03:26
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
You can use "sed":
Code:
cat inputFile | sed -e 's/(.*)/\1,,,/' > outputFile && mv outputFile inputFile
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 12-08-09, 21:36
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 696
vim works nicely here:

Code:
vim '+:%norm A,,,' '+:wq' file
To save it with a different name:

Code:
vim '+:%norm A,,,' '+:w newfile' '+:q!' file
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On