Ever received a large MySQL dump file and only needed one table out of it?

I ran across just this issue. The full database took significant time to import and I only needed a small subsection of the DB, just one single table. Rather than waiting for it all to import, I pulled together a sed command that extracts a single table from the sql file. Check it out:

sed -n ‘/Records of TABLE_NAME/,/Table structure for/p’ FULL_SQL_FILE.sql > table.sql

Replace TABLE_NAME and FULL_SQL_FILE with the names of the table you want and the sql file to pull it from, respectively.

You will now have a table.sql file in your directory that is ready to be imported.

Photo by chuttersnap on Unsplash