0

I'm trying to substitute a specific word that has a newline(mainly using sed), but while trying different things to do so, it seems to not have worked... Here the test input/file:

this # target for substitution
this is a test
another test?

And here are the things i tried:

sed 's/^this/test/' testfile

But this work on the other "this" word too (instead of just the one with the newline)

sed 's/^this\n/test/' testfile

Here i added a \n but while this sometimes works with sed, it doesn't in this case.

Finally, I also tried using word bondaries with \b, but that didn't work either:

sed 's/\bthis\b\n/test/' testfile

Any way to do this? (specifically with sed if possible).

0