Skip to content

Instantly share code, notes, and snippets.

@areina
Forked from jhbabon/cleanup.rb
Created April 16, 2013 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save areina/5395125 to your computer and use it in GitHub Desktop.
Save areina/5395125 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# @see http://stackoverflow.com/a/11522507
if ARGV.empty?
$stdout.puts "Usage: cleanup.rb dump.sql table_a [table_b ...]"
else
args = ARGV.reverse
file = args.pop
output_file = "#{file.gsub(File.extname(file), '')}-cleanup.sql"
pattern = "-E \"INSERT INTO \\`(#{args.join('|')})\\\`\""
`grep -v #{pattern} #{file} > #{output_file}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment