Replacing Square Brackets With Sed

Posted by BadReligion Mon, 28 Sep 2009 21:21:00 GMT

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  | 1 comment