Skip to main content

Concatenate bash commands with arguments (xargs)

We were looking for a way to create mysqldumps which contained all the structures for the tables, but the data only for part of the tables. We wanted to use mysqldump to create dumps of big databases because drupal 'backup and migrate' module would create them using apache.

Using xargs was the elegant way. Thanks to Günter!

mysql -u USER -p DATABASENAME -e 'show tables' | egrep "cache|search" | xargs mysqldump DATABASENAME -u USER -p >> dump_without_cache-search_data.$DATE

Have a look at the link as well - but it's in German.