I'm creating an oracle insert statement using awk but need to be able to escape the ' (forward single quote) as the oralce insert syntax requires these quotes. I've tried \ in and out of quotes etc. It's these single quotes values (' .....')
cat $1 | awk -F"|" '{print "insert into table (data_string) values ('PRICES|"$6"|FOSTRAT|"$24"|||N');"}'
Any ideas anyone ?
What happen if you create an awk file:
my_awk.awk { print "insert into table (data_string) values 'PRICES|"$6"|FOSTRAT|"$24"|||N');" }
cat $1 | awk -F "|" -f my_awk.awk
Regards. Hugo.
For this to work you also have to ensure that all single quotes in the data are duplicated. Try this:
sed -e "s/'/''/g" $1 | awk -F"|" '{ printf "insert into table (data_string) values " printf "(%cPRICES|%s|FOSTRAT|%s|||N%c);\n", 39, $6, $24, 39 }'