Domanda

I just found this:

sed '/label/{n;n;s/{}/{some comment}/;}'

The intended effect is to seek label, proceed 2 lines down (n;n;) then substitute in (s) some comment.

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?

È stato utile?

Soluzione

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.

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.

From man sed:

n N Read/append the next line of input into the pattern space.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top