【发布时间】:2010-11-19 10:37:04
【问题描述】:
我想查看文件 xyz.txt 的任何更改,并在有更改时通过电子邮件将整个文件发送给我。是否有一个 Liner(或几行 shell 脚本)?
更新:
# Check if my.cnf has been changed in the last 24 hours
# if yes, as in the following case, simply send the file
# if it has not been changed in the last 24 hours, do nothing.
# find /etc/ -name my.cnf -mtime 0
/etc/my.cnf
# cat /etc/my.cnf | mail shantanu@company.com
现在,如果有人可以展示如何在 shell 脚本或 1 个命令中绑定这两行。
【问题讨论】:
-
你可以使用
fswatch,它是跨平台且直接的fswatch -o my_file | xargs -n1 -I{} my_program
标签: linux shell command-line