linux - 想要压缩 7 天前的日志文件,然后移动到 Linux 中的不同目录

标签 linux bash shell

虽然这个问题可能是重复的,但我可以找到这个问题的适当答案。我可以找到 7 天前的日志文件并将它们移动到不同的目录,但在将它们移动到不同的目录之前,我想将它们压缩到一个文件中,然后移动压缩的文件。

root@tryit-becoming:~/home# find /root/home/logs -mtime -8 -exec mv '{}' /root/home/ \; 

这是我的代码

最佳答案

你可以使用这个。

find /root/home/logs -mtime -8 -exec zip /root/home/file.zip {} + 

关于linux - 想要压缩 7 天前的日志文件,然后移动到 Linux 中的不同目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52856758/

相关文章:

linux - 使用 bash 取十进制数的平均值

node.js - Ubuntu 中的 cp 命令 - 同步

bash - 在 Bash 中自定义 "command not found"消息

bash - 带参数和 eval 的条件构造

bash - 如何测试 rm 的 GNU 或 BSD 版本?

shell - 用于克隆/快照 Docker 容器(包括其数据)的脚本?

arrays - 数组中的空格和换行符(Shell脚本)

linux - 打开 ssh 连接卡住

linux - 默认 Udev 规则

php - xterm 中的换行问题