Can't chain multiple sed commands

2019-09-06 20:29发布

问题:

I have four sed expressions chained up in one command, like so:

sed -e 's/.$//' -ne '/**#@+/ {p; r index.html' -e ':a; n; /**#@-*/ {p; b}; ba}; p' -e '/**#@+/d' input.txt > output.txt

However, the last one seems to fizzle (do nada). If I move it to the front of the chain, it executes correctly, but then my file is not how I want it to be (obviously).

Tested individually, all four commands work fine and do just what I want them to: replace a block of text with something else, get rid of the start & end markers and convert line-endings.

What's preventing the last command -e '/**#@+/d' from chaining? It's all on CentOS 7.

标签: linux bash sed