Why does this script send two emails instead of one?
#!/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!"
"[email protected],[email protected]"
done
Note that
A && B || C
is notif-then-else
. C may run when A is true.