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

 

相关文章:

  • 2021-08-27
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2021-09-27
猜你喜欢
  • 2021-09-15
  • 2021-12-26
  • 2022-01-12
  • 2021-06-13
  • 2022-01-08
  • 2021-10-23
  • 2022-02-05
相关资源
相似解决方案