Sed replace path with slash separators by using a different separator char.

If you have an environment variable that contains a slash like a path, let say

addons_path = /home/netjunky/projects/odoo-dev/odoo/openerp/addons

and you want to replace “addons_path = /home/netjunky/projects/odoo-dev/odoo/openerp/addons” with “addons_path = /home/netjunky/projects/odoo-dev/odoo/custom/addons” using sed, usually you would try something like this

sudo sed -i  ‘s/addons_path = */addons_path = /home/netjunky/projects/odoo-dev/odoo/custom/addons/’ /home/netjunky/projects/odoo-dev/odoo/config/openerp-server.conf

this raise an error like

sed: -i expression #1, char 9: unknown option to `s’

but if you try

sudo sed -i  ‘s|addons_path = *|addons_path = /home/netjunky/projects/odoo-dev/odoo/custom/addons,|’ /home/netjunky/projects/odoo-dev/odoo/config/openerp-server.conf

It works!!!

You can use any other separator instead of |.

 

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!