I am using sed -e "s/foo/$bar/" -e "s/some/$text/" file.whatever to replace a phrase in a certain file. The problem is that the $bar string contains multiple special characters like /. So when I try to replace something in a text file using the following code…
#!/bin/bash
bar="http://stackoverflow.com/"
sed -e "s/foo/$bar/" -e "s/some/$text/ file.whatever
…then I get an error saying : sed: unknown option to s is there anything I can do about it?
You can use any delimiter.
s@some@SOME@for example. Another good delimiter is vertical-bar. Other chars can work but have special significance for some contexts such as regular expressions.