Hi I want to delete a line using sed if it matches 2 regular expressions in the same line. EG the line starts with /* and end with */ (comment). The following script will do m
Try
sed '/^\/\*.*\*\/$/ d' filename
The key here is that you can sorta combine two regex patterns into one, simply by connecting them with .*
, which matches "any number of any character". Of course, this enforces an ordering between the two. The first pattern ^\/\*
must occur before the second one \*\/$
for this particular pattern to match.
Also, since *
has special meaning in regex, be sure to escape your astrices, just as you have to escape your slashes.