![将多个命令合并在一行中](https://linux22.com/image/211520/%E5%B0%86%E5%A4%9A%E4%B8%AA%E5%91%BD%E4%BB%A4%E5%90%88%E5%B9%B6%E5%9C%A8%E4%B8%80%E8%A1%8C%E4%B8%AD.png)
#!/bin/sh
export origin=/home/user
export dest=/home/temp
find $origin -iname "*.png" -mtime -5 -exec cp "{}" $dest \;
find $origin -iname "*.png" -mtime -5 -exec zip $dest/png.zip "{}" \;
find $origin -iname "*.png" -mtime -5 -printf "%TY-%Tm-%Td %p\n"
我创建了一个脚本来查找 5 天前的文件。然后将其复制到临时文件夹中,然后压缩。之后,我显示找到的内容。我可以将 3 个命令或至少前 2 个命令合并在一行中吗?
答案1
我会尝试
find $origin -iname "*.png" -mtime -5 -exec cp "{}" $dest \; -exec zip $dest/png.zip "{}" \; -printf "%TY-%Tm-%Td %p\n"