Using sed to delete a line having a particular keyword

Hi Geeks :b:,
I need to delete a line from file that contains a particular keyword.
I had read in some forum of unix.com that below code could be used

sed "/$titlesearch/d" movielist >tmp
mv tmp movielist

But my file contains lines which contain slashes (/)
FOr eg:
/etc/movie/title/
/etc/movie2/tiltle2/

$titlesearch is a variable that contains any of the above line to delete

But when I execute it gives me error like
Unrecognized command: /etc/movie/title//d

I think it is happening because of slashes :confused: Please suggest
Thanks in advance

If u want to use perl:

perl -ane "print unless  m.${titlesearch}.;" movielist>tmp

If using perl, you can update the file directly with -i.

perl -i.bak -ane "print unless  m.${titlesearch}.;" movielist

by awk:

awk -v t=$titlesearch '!($0~t)' movielist > tmp

It is not working:
Unrecognized command: _

---------- Post updated at 08:41 AM ---------- Previous update was at 08:39 AM ----------

Could you please explain the awk command. Especially '!($0~t)'

you can use any character as sed separator like

sed "|$titlesearch|d" movielist
sed "#$titlesearch#d" movielist

just look that it isn't used in your list

HI Klashxx/rdcwayx,

The perl thing worked, Could you please mind explaining the code.

Thanks in adv.