LQ Newbie
Registered: Nov 2010
Posts: 1
Rep:
|
sed - Problem appending at the end of line
Hi,
Using sed, I am trying to append four commas ',,,,' at the end of lines containing the pattern 'Response' in a text file with lines such as these:
6,Pulse,50,254968,14886,NA,,,,
7,Picture,8,265157,0,1,15045,2,0,15000
7,Response,1,271553,6396,1
7,Pulse,50,274969,9812,NA,,,,
8,Picture,1,290232,0,1,15045,2,0,15000
8,Pulse,50,294969,4737,NA,,,,
8,Response,1,296837,6605,2
8,Pulse,50,314970,24738,NA,,,,
9,Picture,4,315307,0,1,15045,2,0,15000
9,Response,1,321090,5783,1
9,Pulse,50,334971,19664,NA,,,,
10,Picture,14,340382,0,1,15045,2,0,15000
10,Response,1,350102,9720,2
The script I am using for this is
sed -i '/Response/s/$/,,,,/'
However, when I run the scrip, the commas are appended in a new line inserted after the line with the pattern. When I open the modified txt file it looks like this:
6,Pulse,50,254968,14886,NA,,,,
7,Picture,8,265157,0,1,15045,2,0,15000
7,Response,1,271553,6396,1
,,,,
7,Pulse,50,274969,9812,NA,,,,
8,Picture,1,290232,0,1,15045,2,0,15000
8,Pulse,50,294969,4737,NA,,,,
8,Response,1,296837,6605,2
,,,,
8,Pulse,50,314970,24738,NA,,,,
9,Picture,4,315307,0,1,15045,2,0,15000
9,Response,1,321090,5783,1
,,,,
9,Pulse,50,334971,19664,NA,,,,
10,Picture,14,340382,0,1,15045,2,0,15000
10,Response,1,350102,9720,2
,,,,
Any idea what's wrong here and how to get the desired result?
Many thanks
Last edited by jdom; 11-05-2010 at 12:49 AM.
Reason: Spaces between lines were automatically inserted
|