Remove path string from file (string contains "/")

This is the way

sed -i 's/home/$USER/.config/hello_there//g' /home/$USER/.gnomerc

But, as far as I saw you cannot add any "/" in the string you want to remove....
So, what should I do in order to remove this path (which contains "/") ?:confused:

sed -i 's#home/$USER/.config/hello_there##g' /home/$USER/.gnomerc

Amm, thanks, this worked supposing you know the name of the Variable $USER....
e.g.
sed -i 's#home/alex/.config/hello_there##g' /home/$USER/.gnomerc #WORKS
sed -i 's#home/$USER/.config/hello_there##g' /home/$USER/.gnomerc #DOESN'T WORK

sed -i "s#home/$USER/.config/hello_there##g" /home/$USER/.gnomerc

Always solving one problem at a time :wink:

1 Like

Use double quotes :):

sed -i "s#home/$USER/.config/hello_there##g" /home/$USER/.gnomerc
1 Like

Thank you all.

# sed -i 's/home\/'$USER'\/.config\/hello_there//g' /home/$USER/.gnomerc
1 Like

Thanks, this solution works as well.