I try to use sed within a bash script in order to replace ' with ''
I have to do so because of an Oracle DB, but I cannot find the right syntax.
So far I have tried:
sed -e 's/(')/('')/g' List_employees_a.csv > List_employees.csv
sed -e 's/'/''/g' List_employees_a.csv > List_employees.csv
sed -e 's/'/\'\'/g' List_employees_a.csv > List_employees.csv
sed -e 's/\'/\''/g' List_employees_a.csv > List_employees.csv
This sed should work:
sed 's/'\''/'\'''\''/g'
OR use double quoted for delimiters:
sed "s/'/''/g"
OR more verbose:
sq="'"
dq="''"
sed "s/$sq/$dq/g" file
The problem isn't sed, it's that your shell is parsing the quotes before they ever get to sed. One really easy way to avoid this is to use a script file:
sed -f script_file List_employees_a.csv > List_employees.csv
where the content of script_file is:
s/'/''/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With