Return to Snippet

Revision: 4322
at November 28, 2007 12:55 by ches


Updated Code
ruby -ne '@found=true if $_ =~ /^CREATE TABLE `foo`/i; next unless @found; exit if $_ =~ /^CREATE TABLE (?!`foo`)/i; puts $_;' giant_sql_dump.sql > foo.sql

Revision: 4321
at November 27, 2007 10:55 by ches


Initial Code
ruby -ne '@found=true if $_ =~ /^CREATE TABLE `foo`/i; next unless @found; puts $_; exit if $_ =~ /^CREATE TABLE (?!`foo`)/i' test.sql > my_table.dump

Initial URL

                                

Initial Description
Courtesy of Jesse.

Initial Title
Ruby One-liner for Restoring One Table from a Huge SQL Dump

Initial Tags
database, sql, backup, ruby

Initial Language
Ruby