加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 观看文件以进行更改

发布时间:2020-12-13 17:00:30 所属栏目:Linux 来源:网络整理
导读:我想观看文件xyz.txt的任何更改,并在发生更改时通过电子邮件发送给我整个文件.是否有一个衬里(或几行 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
我想观看文件xyz.txt的任何更改,并在发生更改时通过电子邮件发送给我整个文件.是否有一个衬里(或几行 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命令中绑定这两行.

解决方法

尝试一下:
find /etc/ -name my.cnf -mtime 0 -exec sh -c 'cat {} | mail -E -s "file changed" shantanu@company.com' ;

邮件的-E选项阻止它发送带有空体的消息(如果find返回任何内容并且cat不输出任何内容,则会出现这种情况).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读