Bill Karwin's answer is really good, and even I was using a similar solution, until yesterday when I got a message field which has a "\" character, which was escaped with "\" and as it was the last character of the field, the next character was a single-quote, marking the end of the string field content. Now, here's the string a the solution below, I used Perl regex "look-behind":
INSERT INTO "My_table" VALUES ('Table_1','316947','[email protected]','Richard','[email protected]','Skip\\','HAPPY VISHU<br></b>\r\n\r\n\r\n')
Solution: with 2 examples:
[pradeep@ubuntu ~]# cat /tmp/a.txt
INSERT INTO "My_table" VALUES ('Table_1','316947','[email protected]','Richard','[email protected]','Skip\\','HAPPY VISHU<br></b>\r\n\r\n\r\n')
INSERT INTO "My_table" VALUES ('Table_1','316947','[email protected]','Richard','[email protected]','Pradeep\'s Skip\\','HAPPY VISHU<br></b>\r\n\r\n\r\n')
[pradeep@ubuntu ~]# cat /tmp/a.txt | perl -pe 's/(?<!\x5c)\x5c\x27/\x27\x27/g;' | perl -pe 's/(\x5c\x5c)+\x5c\x27/$1\x27\x27/g;'
INSERT INTO "My_table" VALUES ('Table_1','316947','[email protected]','Richard','[email protected]','Skip\\','HAPPY VISHU<br></b>\r\n\r\n\r\n')
INSERT INTO "My_table" VALUES ('Table_1','316947','[email protected]','Richard','[email protected]','Pradeep''s Skip\\','HAPPY VISHU<br></b>\r\n\r\n\r\n')