My /etc/apt/sources.list
contains this line :
deb http://downloads.sourceforge.net/project/xenlism-wildfire/repo deb/
I want to remove that line via sed
in command line, so I tried this code but returns error !
$ sudo sed 's:deb http://downloads.sourceforge.net/project/xenlism-wildfire/repo deb/::g' /etc/apt/sources.list
sed: -e expression #1, char 75: unknown option to `s'
I guess the symbol :
after http
caused this error, but how can I fix it?
You can use any* symbol to delimit the search/replace strings which does not conflict with symbols in the strings, as long as you use it consistently, e.g.:
This reduces the need to escape a problematic character (which could be done using
\
as an escape).*I am sure there are exceptions, especially if using older versions of
sed
, but I'm not aware of any limitations off hand.Run like this:
The problems I fixed:
-i
flag to modify the file in-place. Without that, the command would just print the output ofsed
to the screen, without updating the file.s///
to replace the line with empty string, I used thed
command to delete the line./.../
, I used\%...%
, because%
doesn't appear in the pattern. With/
, all occurrences of/
would have to be replaced.Note that possibly a simpler filter might be good enough. For example if you know that
xenlist-wildfire
is unique in the file, then this simpler command will work too:Since in this example there is no
/
, I could use the simpler/.../
filter.(Thanks for @steeldriver for the improvement ideas.)