Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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\'
and multiple lines goes here',35,10,'meh')


VALUES(E'blah blah blah',E'second string \'with escaped\'
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
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


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.