Monday, May 30, 2011

substitute within a range


In this case we will see how we can use sed command within a particular range

for example we try to substitute the words inbetween wonderful and marvellous.
leaving behind the first and last word.

Content of the file to be modified:

acer@ubuntu:~$ cat ggg
hello life
wonderful
great
marvellous
awesome

OUTPUT with execution:

acer@ubuntu:~$ sed '/wonderful/, /marvellous/ s/.*/modified/' ggg
hello life
modified
modified
modified
awesome
acer@ubuntu:~$

No comments:

Post a Comment