multiline sed using backreferences...

Posted by pagid on Stack Overflow See other posts from Stack Overflow or by pagid
Published on 2010-05-10T23:02:37Z Indexed on 2010/05/10 23:04 UTC
Read the original article Hit count: 221

Filed under:
|

Hi, I'm converting patch scripts using a commandline script - within these scripts there's the combination two lines like:

--- /dev/null
+++ filename.txt

which needs to be converted to:

--- filename.txt
+++ filename.txt

Initially I tried:

less file.diff | sed -e "s/---\/dev\null\n+++ \(.*\)/--- \1\n+++ \1/"

But I had to find out that multiline-handling is much more complex in sed :(

Any help is appreciated...

© Stack Overflow or respective owner

Related posts about sed

Related posts about regex