Delete all lines from file matching a string

I wish to search and delete all lines in /app/Jenkins/deploy.txt having this filename string /app/Jenkins/file2.mrt as entry:

I'm using : colon as delimiter in sed command as I'm dealing with file paths.

Below is the command I was expecting to work.

sed -i ":/app/Jenkins/file2.mrt:d" /app/Jenkins/deploy.txt

However, the deploy.txt file remains unchanged.

I'm on the latest version of RedHat Linux

Can you please suggest if I'm missing something ?

Sometimes, reading man pages really helps. man sed :

Looks like you need to escape the first colon.

1 Like