Find and delete the line

Hi I have a text file like this name today.txt

the request has been accepted
the scan is successful at following time
there are no invalid packages
5169378 : map : Permission Denied
the request has been accepted

Now what i want do is

I want to search the today.txt file and

if i find "permission denied" then I have to delete the whole line.
so that the text looks like this,

the request has been accepted
the scan is successful at following time
there are no invalid packages
the request has been accepted

Any help is appreciated,

gns.

Try:

grep -v "Permission Denied" today.txt

Hi

if I do

grep -v "Permission denied" today.txt
It is printing the text without the line on the screen

but it si not deleting the line in the file.

So how can I do that, like delete the line from the file itself as i am mailing the file after i do this operation.

Regards,

gns

PS: Sorry for multiple posting

If i do this

grep -v "Permssion Denied" todat.tx >today.txt 2>&1

its not working

Please help me,

Gns

Do a quick search on this forum for simple sed commands. I'm not handy with sed myself, but it will allow you to do exactly what you want -- edit the file in one step.

Be very careful whenever and wherever you use ">myfile" at the end of any command, the content of "myfile" will be cleared completely.

So, doing:

grep -v "bla bla bla" myfile >myfile

will first emty myfile before executing the grep!!!

Having that in your mind, you have to do the following:

grep -v "Permission Denied" today.txt >tmp.txt; mv tmp.txt today.txt
sed "/Denied/ d" test.txt > tmp.txt && mv tmp.txt test.txt

Im trying to do the same but with a variable passed to the sed command ;

sed "/$var/d" test.txt > tmp.txt

I tried this as well..
sed "/'$var'/d" test.txt > tmp.txt

But its not working. Could you guide me on what is wrong ? Or is there a different way to specify the variables ?

Its working without the ''. I couldnt delete the post. Sorry !