Splitting up a huge file on one line with sed

icon3 , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Posted August 3, 2009 at 23:59 (UTC)

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

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.