Replacing Square Brackets With Sed

Posted 10 months ago

For me the following do not work:

sed 's/(\[|\])//g'
sed 's/[[]]//g'
The following do work:
sed 's/[][]//g'
sed -e 's/\[//g' -e 's/\]//g'

Example:

echo '[foobar]' | sed 's/[][]//g'
>foobar

echo '[foo]bar' | sed 's/[][]//g'
>foobar

The environment is Debian 4.0, GNU sed version 4.1.5.

Posted in ,  | Tags  | no comments

Comments

(leave url/email »)

   Comment Markup Help Preview comment