linux remove lines from file

C++
sed -i '' '/pattern to match/d' ./infile
> sed '2,4d' file

Source

Also in C++: