In my program, I would like to first get the user input, and insert a \ before each /
so I write this, but it doesn't work.
echo "input a website"
read website
sed '/\//i\/' $website
In my program, I would like to first get the user input, and insert a \ before each /
so I write this, but it doesn't work.
echo "input a website"
read website
sed '/\//i\/' $website
You can also use Parameter-Expansion to replace sub-strings in variable. For example:
website="https://stackoverflow.com/a/58899829/658497"
echo "${website//\//\\/}"
https:\/\/stackoverflow.com\/a\/58899829\/658497