Remove text between two patterns

This can be done in UNIX by using SED For example: I want to remove the text between foo and bar

 

file.txt contains:

white

green

blue

foo

red

black

bar

yellow


sed '/foo/,/bar/{d;}' file.txt


Output:

white

green

blue

red

black

yellow

Hope this helps!!!


Related Posts


No comments: