How can I append text below the specific number of lines in sed?
More specifically, if I have following 'Target' file,
$ cat Target
##########
# (1)
##########
echo $PWD
##########
# (2)
##########
##########
# (3)
##########
How can I insert a line between '# (2)' block and '# (3)' block? In other world, I want to create 'Goal' file like this by using sed.
$ cat Goal
##########
# (1)
##########
echo $PWD
##########
# (2)
##########
echo "yay"
##########
# (3)
##########
I tried various ways and googled a lot, I cannot find any clue. (Why special pattern '\n' does not work?)
Please give me an advice.