这个问题来自 如何删除多行文本文件中大括号之间的所有文本?(只是一样,但没有嵌套的要求)。
例子:
This is {
{the multiline
text} file }
that wants
{ to {be
changed}
} anyway.
Run Code Online (Sandbox Code Playgroud)
应该变成:
This is
that wants
anyway.
Run Code Online (Sandbox Code Playgroud)
是否可以使用某种单行 bash 命令(awk、sed、perl、grep、cut、tr...等)来做到这一点?