3

为什么此脚本发送两封电子邮件而不是一封?

#!/bin/sh
MONITORDIR="/path/to/directory"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read 
NEWFILE
do
[  -z "${NEWFILE}" ] && : || MOVIE=$(find "$NEWFILE" -type f -not -name ".*" 
\( -iname "*.mkv" -o -iname "*.mp4" -o -iname "*.avi" \) -exec basename {} 
\; | sed 's/\.[^.]*$//')
[  -z "${MOVIE}" ] && : || echo "Please don't reply to this 
automatically generated email message." | mail -s "$MOVIE is now on Plex!" 
"email1@gmail.com,email2@gmail.com"
done
4

1 回答 1

2
[  -z "${MOVIE}" ] && : || echo "Please don't reply to this 

注意A && B || C不是if-then-else。当 A 为真时,C 可能会运行。

于 2017-09-25T02:29:43.337 回答