Here is example file:
somestuff...
all: thing otherthing
some other stuff
What I want to do is to add to the line that starts with all:
like this:
somestuff...
all: thing otherthing anotherthing
some other stuff
This works for me
sed '/^all:/ s/$/ anotherthing/' file
The first part is a pattern to find and the second part is an ordinary sed's substitution using $
for the end of a line.
If you want to change the file during the process, use -i
option
sed -i '/^all:/ s/$/ anotherthing/' file
Or you can redirect it to another file
sed '/^all:/ s/$/ anotherthing/' file > output