Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm attempting to convert a mysqldump output file to PostgreSQL compatible SQL. The issue is in dealing with escaped string values.

I need to go from:

VALUES('blah blah blah','second string \'with escaped\'
quotes 
and multiple lines goes here',35,10,'meh')

to:

VALUES(E'blah blah blah',E'second string \'with escaped\'
quotes 
and multiple lines goes here',35,10,E'meh')

Notice the addition of the "E" before each single-quoted string.

How can this be accomplished in sed? Also open to using other regex engines as long as I can stream them (dealing with multi-GB files here).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It occurred to me that this is not an uncommon usage scenario, so I checked PostgreSQL's site to see if they have solutions -- and indeed they list several tools to do the job. Hopefully one of them works for you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.