Change from 'something' to 'something else
sample.txt
hello outthere
how are
you today
Simple single line match
> sed -i s/hello/goodbye/ sample.txt
goodbye out
there
how are
you today
Multiline replace. Match on 'out'. N adds the next line to the 'match space' and then there is a normal substitution on the 'match space'.
> sed -i "/out/{N;s/there/fred/}" sample.txt
hello out
fred
how are
you today
No comments:
Post a Comment