29

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,438
  • 68
  • 55
  • 126
Thomas
  • 1,123
  • 1
  • 7
  • 14

1 Answers1

40

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
  • 713,503
  • 59
  • 514
  • 593