GREP and TAR all files/directories matching X

1

I would like to find and gzip/tarball contents of all the folders matching wordpress in my directory, but I am having trouble trying to get the command to work, I thought it was something like

find * | tar -zcvf jdaniel/wp-all.tar.gz 'grep wordpress'

tar: Exiting with failure status due to previous errors

ehime

Posted 2011-07-14T22:50:15.687

Reputation: 241

Answers

0

Do the search in the find command instead:

find ./ -iname '*wordpress*' | tar -zcvf jdaniel/wp-all.tar.gz

You could also add -type d to the find command, but not sure if that will skip the files in the directories when they are passed to the tar command.

Matrix Mole

Posted 2011-07-14T22:50:15.687

Reputation: 3 303

0

If you want to archive all the directories in the current directory whose names include "wordpress", then just use this:

tar -zcvf jdaniel/wp-all.tar.gz *wordpress*

That assumes that you're not interested in directories beginning with ".".

garyjohn

Posted 2011-07-14T22:50:15.687

Reputation: 29 085