34

I have a line that says...

Fred Flintstone, Bedrock USA

and I want it to look like...

Fred Flintstone, Bedrock USA ***

How do I append a few * to the end of the line using sed command?

αғsнιη
  • 36,350
Justin
  • 2,151
  • 7
  • 29
  • 32

1 Answers1

50

You can use this:

sed 's/$/ ***/' filename

If you want to search for a specific string before appending to a line (that is you don't want it appended to EVERY line like the above command) you can use the following, this finds Fred Flintstone anywhere in a line, put^ in front if you only want to match the beginning of the line.

sed '/Fred Flintstone/ s/$/ ***/' filename
dragon788
  • 1,716
Cyrus
  • 5,789