I am just using simple sed substitution to replace some strings in a file by reading its value from a variable
cat file.txt
root="/content/drive/Shared drives/Media Library"
# some other lines
# ...
In the above file txt , I am intending to substitute /content/drive/Shared drives/Media Library
in line 1 with the value of a variable path
being read through a bash script .
For example - If i enter /home/user
as value of variable ,the line 1 in file.txt should be modified as follows :
root="/home/user"
Here's my bash script with the sed expression
#!/usr/bin/env bash
read -e -p "Enter the path: " path
sed -i "1s/\/content\/drive\/Shared drives\/Media Library/${path}/" file.txt
When i execute the bash script and enter path as /home/user
, it returns the following error -
sed: -e expression #1, char 52: unknown option to `s'