find 与 tar命令连用

find 与 tar命令连用  

今天打包日志时,用

find -mtime -1 -type f -exec tar -cvf log.tar {} ;

发现只打包了最后一个文件,应该是tar的c参数,每次都创建一个新的文件,想了下用r参数代替,没有问题了

 find -mtime -1 -type f -exec tar -cvf log.tar {} ;

再多试了下,下面2个命令写法也是一样效果:

 tar -cvzf 11.tarz $(find -mtime -1 -type f)
find . -name '*11*.txt' | xargs tar -rvf 11.tar; gzip 11.tar
原文地址:https://www.cnblogs.com/mjorcen/p/3950461.html