{"id":238,"date":"2016-05-19T21:51:25","date_gmt":"2016-05-19T18:51:25","guid":{"rendered":"http:\/\/meekconsulting.com\/?p=238"},"modified":"2022-01-08T16:26:32","modified_gmt":"2022-01-08T13:26:32","slug":"perl-toggle-operator-for-extracting-one-table-from-mysql-dump-file","status":"publish","type":"post","link":"https:\/\/meekconsulting.com\/?p=238","title":{"rendered":"perl toggle operator for extracting one table from mysql dump file"},"content":{"rendered":"<p>We did it with a nifty one liner perl command that uses the TOGGLE operator.<br \/>\n<code><br \/>\nzcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (\/CREATE TABLE `budget`\/..\/UNLOCK\/ ) {print $_; }' > budget.1208.sql<\/code><\/p>\n<p>This looks for lines in the dump between lines that match the green and yellow highlighted words ( which happen to be the separators we want )<\/p>\n<p>We wanted to be able to rename our table so we could load it in the current schema as the live table so we added a substitution before printing like this:<\/p>\n<p><code>zcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (\/CREATE TABLE `budget`\/..\/UNLOCK\/ ) {$_=~s\/budget\/budget_1210\/; print $_; }' > budget.1208.sql<\/code><\/p>\n<p>Good thing to have in your toolkit..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We did it with a nifty one liner perl command that uses the TOGGLE operator. zcat fast.dmp.12082014_13_03.sql.gz |perl -ne &#8216;if (\/CREATE TABLE `budget`\/..\/UNLOCK\/ ) {print $_; }&#8217; > budget.1208.sql This looks for lines in the dump between lines that match &hellip; <a href=\"https:\/\/meekconsulting.com\/?p=238\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/238"}],"collection":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=238"}],"version-history":[{"count":2,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=\/wp\/v2\/posts\/238\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meekconsulting.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}