I am new to shell-scripting, and I have what should be a very simple problem to solve. Unfortunately, I have had no luck finding an answer. I have a filename stored in a string, and I want to be able to use this with sed. In order for that to work, I need to change all instances of "." and "/" into "\." and "\/", respectively.
Is there a one-line command to do this? It seems that there has to be, since this must come up quite often. Thanks in advance for your help!
I'm not running Mac, but Solaris. The default sed seperator is / but I override it using | because I think it's easier to read:
echo "$mystring"|sed -e 's!\/!\\\/!g' -e 's|\.|\\\.|g'
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |