To clarify your mistake, the
[] brackets in regular expressions constitute a list of
individual characters that can be matched at that location. On its own the whole bracket expression matches only a single character on the line.
Code:
sed 's/^[lLbB]oobar/Foobar/g' infile
This will match any line starting with "
loobar", "
Loobar", "
boobar", or "
Boobar", and change that string to "
Foobar". But it will
not match "
bBoobar" or any other multi-character combination.
Similarly.
's/[dc=]//' will match the first "
d", the first "
c",
or the first "
=" on the line (whichever is encountered first), and remove it. It will
not match the whole string"
dc=", although it could match one of the individual characters, if it's the first instance on the line.
I say only the first, because you need to add the "
g" option at the end of the
s/// command to do multiple substitutions on a single line.
I suggest you take some time to really learn how to use regular expressions. You'll be glad you did. Here are a couple of tutorials:
http://mywiki.wooledge.org/RegularExpression
http://www.grymoire.com/Unix/Regular.html
And more about using sed here:
http://www.grymoire.com/Unix/Sed.html
http://sed.sourceforge.net/grabbag/
http://sed.sourceforge.net/sedfaq.html
http://sed.sourceforge.net/sed1line.txt