简体   繁体   English

sed中的命令分组

[英]Command grouping in sed

I do not understand the command grouping in sed scripts. 我不明白sed脚本中的命令分组。 We use curly braces to group commands. 我们使用花括号来分组命令。 I found some information in the first answer to the following question: 我在以下问题的第一个答案中找到了一些信息:
Using multiple sed commands . 使用多个sed命令
But I still do not understand this properly. 但我仍然不理解这一点。 Could someone please explain this to me? 有人可以向我解释一下吗?

If you use 如果你使用

/Number/ s/N/n/;s/r//

Then r s will be removed on all lines, not only those containing Number . 然后将删除所有行上的r s,而不仅仅是那些包含Number But, if you use 但是,如果你使用

/Number/{s/N/n/;s/r//}

then r s will be removed only from lines containing Number . 那么r s只会从包含Number行中删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM