Deleting a line from a file

Bernd Petrovitsch bernd at petrovitsch.priv.at
Thu May 15 03:55:52 EDT 2014


On Mit, 2014-05-14 at 11:18 -0400, Valdis.Kletnieks at vt.edu wrote:
> On Wed, 14 May 2014 16:34:20 +0200, Bernd Petrovitsch said:
> 
> > sed -i 's#^/opt/new1.*$#d' file_entries.txt
> 
> You don't even need the leading 's'.   Just   /pattern/d   is sufficient.

Ooops, yes, thanks. So

sed -i '/\/opt\/new1/d' file_entries.txt

should do it.
Just for the match, we do not need, the tailing ".*$" (because it
matches always). But we need /../,
so just quote the "/" in the path.
The "d" tells "sed" to delete the current line.

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at




More information about the Kernelnewbies mailing list