Aug 3
Splitting up a huge file on one line with sed
icon1 Mikkel Meyer Andersen | icon4 August 3, 2009 at 23:59 (UTC) | icon3 No Comments »
icon3 , ,

Sometimes when I export MySQL to files, I end up having one huge query on one line. It can be quite annoying! I’d rather want it on several lines; in that way it easier to just copy out a fragment of the query. And it also seems that some editors handle several lines better than one huge. Well, in this case my line looked like this:

INSERT INTO TABLE VALUES (...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...),(...);

With this sed-command, every entry got its own line:

sed s/\),\(/\),\\n\(/g export.sql > one-per-line.sql