Re: sed: How do you match a string containing square brackets AND hyphens?
On 23 Aug 2006 08:00:13 -0700, Dave S. wrote:
> The streaming editor (sed) allows us to use the metacharacters "[" and
> "]" to match any one of a number of characters. According to the
> Pattern Matching chapter in O'Reilly's book Unix in a Nutshell by
> Daniel Gilly, "A hyphen or close bracket (]) as the first character is
> treated as a member of the list."
[...]
$ echo '[]-' | sed 's/[][-]/+/g'
+++
See also: sed 'y/[]-/+++/'
--
Stephane
|