I'm trying to run a sed command in a bash script I have which replaces a string between two quotation marks from another file with another string.
The file I'm editing:
path="text"
Bash script:
userPath=$(pwd)
sed -i 's/path=".*"/path="${userPath}"/g' file
but after running the script, my file gets edited as this instead of the actual path that gets outputted from the pwd (etc. path="/home/Downloads") command:
path="${userPath}"
I tried replacing the single quotes on the outside to double quotes, but I got some "unknown option to 's'" error when running the script. Attempting to add extra quotes and escape them like below did not work either.
sed -i 's/path=".*"/path="\"${userPath}\""/g' file