如果某个文件夹被修改,我想收到一封电子邮件提醒,但如何管理命令的输出,以便它发送一封电子邮件,而不只是显示终端中文件夹的更改?
类似以下内容但......在电子邮件部分中出现错误
inotifywait -m /home/tom -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
| /usr/bin/Mail -s "notify" "email@12345mail.com"
done
答案 0 :(得分:2)
你可能只是错过done
之前的分号吗?
此行适用于我(注意我还使用mutt
代替Mail
):
inotifywait -m /home/tom -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" | /usr/bin/mutt -s "notify" "email@12345.com" ;done