I have to write short script to replace line in file. Some of the lines contains slashes and left square brackets (probably right also).
I know that another delimiter should be used to replace line with slashes.
My code:
sed -i -e "s|${oldLine}|${newLine}|g"
This throws an error because line contains [.
Example String in line to change (oldLine variable):
// List exampleList = [
Example how like should look after change:
List exampleList = [
How to make it works when there are some chars like [
To reproduce:
sed -i -e 's|// List exampleList = [|List exampleList = [|g' test.txt