35

I try to delete all lines that begin with some optional special chars followed by blubb:

That's the lines I want to match:

#blubb
*blubb
-blubb
blubb

That should do it, but doesn't work :(

sed "/^.?blubb$/d" -i special.conf  
sed "/^[#*-]?blubb$/d" -i special.conf  

Has somebody the right solution?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Thomas
  • 1,193
  • 1
  • 7
  • 16

1 Answers1

45

Use this sed command:

sed -i.old '/^[#*-]\{0,1\}blubb/d' special.conf

OR

sed -i.old -E '/^[#*-]?blubb/d' special.conf

OR

sed -i.old -r '/^[#*-]?blubb/d' special.conf
anubhava
  • 761,203
  • 64
  • 569
  • 643