I was struggling with this on Mac. Plus, I needed to do it using variable replacement. So
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.
Picked
I picked the '' from this comment.
The
The thing to note here is use of double quotes in "/$pattern/d". Variable won't work when we use single quotequotes.