This is what I have so far, tried multiple ways but can\'t get it just right. My goal is to sanitize the input to prevent problems while inputting to mysql from text file
<
I'm not sure if I got the problem correctly. If you want to replace all occurrences of a single quote by a dot, use tr
:
tr "'" "." < file.txt > sanitized.txt
If you want to escape the single quote with a backslash use sed
like this:
sed "s/'/\\\'/g" file.txt > sanitized.txt
Note: Please take the advice from CharlesDuffy seriously. This is far from a stable and safe solution to escape values for an SQL import.