| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
On 25 Sep 2014 14:42:01 -0700, "[email protected] [sed-users]"
<[email protected]> wrote:
> Hi.
>
> I just discover that an empty address may be negated (GNU sed 4.2). For
> instance, "!p" is a valid syntax and acts as a nop. Formerly, an
> instruction should be described as [address][!][function] and not as
> [address[!]][function] as I thought until now.
>
> I don't see any use for this except as a way to comment a valid
> instruction. Any idea?
It is documented in the info page and works as expected. A null address
(that is, a command with no address) matches all the lines, so negating it
matches no lines, and the associated command is never executed.
From the info page:
Appending the `!' character to the end of an address specification
negates the sense of the match. That is, if the `!' character follows
an address range, then only lines which do _not_ match the address range
will be selected. This also works for singleton addresses, and,
perhaps perversely, for the null address.
--
D.