Reputation: 11623
In a directory, is it possible to gzip only files containing "foo"? I can find them all by find . -name "*foo*"
but i need a way to archive them.
Thank you.
Upvotes: 0
Views: 269
Reputation: 3175
I assume you mean archive into a single tar file? Not individual .gz files? Try this: (assumes there aren't too many files)
find . -name "*foo*" | xargs tar cvzf archive.tar.gz
An alternative is to do something like:
find . -name "*foo*" > list.txt
tar cvzf archive.tar.gz -T list.txt #(works only with gnu tar, not bsd i think)
Upvotes: 1