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 > adding to each line

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-05, 21:38
peeves peeves is offline
Registered User
 
Join Date: Jan 2005
Posts: 1
adding to each line

hi!

i need to add a string to each line of a file.
i am using
sed -e 's/$/&,OM6500/g' <$filename>$new_filename

but this adds the string ",OM6500" to the last line which is a blank line. How can i avoid that.
as an example, this is what a sample line has right now
2004-07-16,00:07:00,unknown macAddr,OCLD-NEND,1-OPT-1,0.0,0.0,0.0,0.0,0,0.0,0

and the line should look like
2004-07-16,00:07:00,unknown macAddr,OCLD-NEND,1-OPT-1,0.0,0.0,0.0,0.0,0,0.0,0,OM6500

thanks
Reply With Quote
  #2 (permalink)  
Old 01-07-05, 06:41
saurav101 saurav101 is offline
Registered User
 
Join Date: Oct 2003
Posts: 19
Hello
I tried this and it worked
sed -e 's/$/\,OM6500/g' $filename > $new_filename

Check it out and let me know .
Thanks
Saurav
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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