In a directory, is it possible to gzip only files containing "foo"? I can find them all by find . -name "*foo*"
find . -name "*foo*"
but i need a way to archive them.
Thank you.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.