ncsuapex
01-14-2005, 05:16 PM
I am trying to delete lines in a file that has a certain pattern in it. I want to seach the file, for a word or phrase and then have ever line that matches that pattern deleted.
I have tried sed and searched and searched and read through the man pages and ive tried ever possible way to use sed and it's not working. Below are the sed scripts I have tried.
sudo sed -n "pattern /d /g" file
sudo sed -n '/pattern/d' file
sudo sed -n "/pattern/ /d " file
sudo sed -n '/pattern/ /d ' file
sudo sed -n '/pattern/ /d /g' file
sudo sed -e '/pattern/ /d /g' file
I have been able to run the command to print the pattern and it works fine. But when I run the same command but replace the /p with a /d it doesnt work.
sudo sed -n '/pattern/p' file
I am running Debian Sarge. Any ideas on how to get this to work? Or any Ideas on a better way to do what Im trying to do??
I have tried sed and searched and searched and read through the man pages and ive tried ever possible way to use sed and it's not working. Below are the sed scripts I have tried.
sudo sed -n "pattern /d /g" file
sudo sed -n '/pattern/d' file
sudo sed -n "/pattern/ /d " file
sudo sed -n '/pattern/ /d ' file
sudo sed -n '/pattern/ /d /g' file
sudo sed -e '/pattern/ /d /g' file
I have been able to run the command to print the pattern and it works fine. But when I run the same command but replace the /p with a /d it doesnt work.
sudo sed -n '/pattern/p' file
I am running Debian Sarge. Any ideas on how to get this to work? Or any Ideas on a better way to do what Im trying to do??