| tee | tee -a 同时追加到文件 |
|---|---|
| xargs | -n 每批数量、-I{} 占位、-0 空字符分隔 |
| 组合 | find -print0 | xargs -0 |
典型用法
典型用法
df -h | tee /var/log/disk-snapshot.log
find /tmp -name '*.tmp' -print0 | xargs -0 -r rm -f
find /data -type f -name '*.log' | xargs -n 50 -r sha256sum > /tmp/logs.sha256
ls *.rpm | xargs -I{} cp -v {} /data/repo/xargs 拼出的命令执行前先 echo 预演一遍,确认文件清单与参数无误。