sed-大括号表示法是什么?
我刚发现这个:
sed '/label/{n;n;s/{}/{some comment}/;}'
预期的效果是寻找label
,沿(n;n;
)下2行,然后用(s
)some comment
代替.
The intended effect is to seek label
, proceed 2 lines down (n;n;
) then substitute in (s
) some comment
.
这是我从来都不知道sed
拥有的惊人功能.
This is an amazing capability I never knew sed
had.
有人会友好地指定这种花括号符号的名称,以及花括号内的运算符类别的名称吗?
Would someone be kind enough to specify the name of this curly brace notation, and the name of the class of operators inside the braces?
通过括号将多个命令分组,以便在相同的地址范围内执行这些命令(
Curly brackets allow to group several commands so that they are executed for the same address range (reference). The thing here is that you specify an address (with one or two line numbers or patterns) and then apply a group of commands to matching lines.
n
命令没什么特别的,它记录在man
和链接的文档中.我不确定是否有通用名称.
The n
command is nothing special, and it's documented in man
, as well as in the linked document. I'm not sure if there's a general name for it.
来自man sed
:
n N将下一行输入读/追加到模式空间.
n N Read/append the next line of input into the pattern space.