I was struggling with this on Mac. Plus, I needed to do it using variable replacement.
So I used:
sed -i '' "/$pattern/d" $file
where $file
is the file where deletion is needed and $pattern
is the pattern to be matched for deletion.
I picked the ''
from this comment.
The thing to note here is use of double quotes in "/$pattern/d"
. Variable won't work when we use single quotes.