Click to See Complete Forum and Search --> : Sed appending to the end of a line


nitecreeper04
09-12-2004, 07:33 PM
I am trying to figure out how t o append a string to the end of a line suing sed. I am able to append the string to the next line but not the end of the file.

Example1: sed '/^Fred /a\
***' datebook.txt > testfile

Fred
***

But what I want to do is
Fred***

I have tried the end of line marker $ but it doesn’t seem to work. Any suggestions on how to do this with sed?

Thx

EnigmaOne
09-12-2004, 08:09 PM
Have you tried:
sed '/^Fred /i\
***' datebook.txt > testfile

bwkaz
09-12-2004, 08:54 PM
sed -e 's/^Fred .*$/&****'

The $ anchors the match regex to the end of the line, and the & in the replacement expands to "the entire pattern that matched".