I'm writing a bash script where I need to replace text in a file with a specific file path, but my understanding is that sed
does not work with specific characters such as /
. I'm wondering if there is some way around this?
Here is my script currently:
currentdir="$PWD"
filepathvar="${currentdir}/settings.ini"
sed -i -e "s/filepath/$filepathvar/g" aimparmstest
When I print out filepathvar
everything is as I expect it to be, but it seems the fact that filepathvar
contains special characters, it gives me the following error:
sed: -e expression #1, char 13: unknown option to `s'
Is there any way around this? Or perhaps another command I can use? I haven't had any success with changing around the parameters. Any help is greatly appreciated.