I am very new to sed, and everything I find is a little bit here, a little bit there.
I have a text file which contains a block like the following:
#start
a
b
c
#whatever
…
Obviously, that’s a simplified version. I would like to append a line to the end of the #start
block to give me:
#start
a
b
c
d
#whatever
…
I can sort of locate the block with the following:
sed -n '/^#\s*start/,/^$/ p' data.txt
so I think that’s in the right direction. However:
- the selection includes the empty line, which I don’t want
- I can’t work out how to add another line after the match