MySQL: extracting the whole database: sed -n '/^-- Current Database: `databaseName`/,/^-- Current Database: `/p' /path/to/the/fill/dump.sql > output.sql single table: sed -n '/^CREATE TABLE `tableName`/,/^\-\- Table structure for table /p' /path/to/the/fill/dump.sql > output.sql [via this blog] PostgreSQL: pv dump.sql | perl -ne 'print if /^COPY public.name_of_the_table/ .. /^\\\.$/' > out.sql [ via https://stackoverflow.com/a/62289905 ]