sed-大括号表示法是什么? [英] sed - what is this curly brace notation called?

查看:118
本文介绍了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.

这篇关于sed-大括号表示法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆