I need to append a URL (http://localhost:3128
) contained in the $http_proxy
env var at the end of all the lines starting with PATTERN
of a single file.
$ sed "/^PATTERN/ s/.*/& test/" somefile
It works quite well, but as soon as I replace test
with $http_proxy
, sed will complain because of the //
inside it:
$ sed "/^PATTERN/ s/.*/& $http_proxy/" somefile
sed: -e expression #1, char 25: unknown option to `s'
So I tried using #
as a separator (as suggested here for instance), but then sed
doesn't have any effect, like if the pattern suddenly didn't match anymore:
$ sed "#^PATTERN# s#.*#& $http_proxy#" somefile
Any idea?