X-Git-Url: https://code.delx.au/mediapc-tools/blobdiff_plain/527be7ae1668d9ebc0c3450233299c6c618830a7..1c7fa10015a5f6970bc0e8de76fe02ced5edb430:/monitor-dir diff --git a/monitor-dir b/monitor-dir index 6f1c940..baf02e4 100755 --- a/monitor-dir +++ b/monitor-dir @@ -1,18 +1,18 @@ #!/bin/bash -e # Use with crontab entry like: -# */5 * * * * $HOME/bin/monitor_dir /path/to/something +# */5 * * * * $HOME/bin/monitor-dir /path/to/something if [ -z "$1" ]; then - echo "Usage $0 dir [monitor_file]" - exit 1 + echo "Usage $0 dir [monitor_file] [ls]" + exit 1 fi -mon="$1/${2:-.monitor_dir}" +mon="${2:-$1/.monitor_dir}" mon_tmp="${mon}_tmp" -ls -R "$1" > "$mon_tmp" +${3:-ls} "$1" > "$mon_tmp" if [ -r "$mon" ] && ! cmp -s "$mon" "$mon_tmp" && [ -n "$(ls "$1")" ]; then - cat "$mon_tmp" + comm -13 "$mon" "$mon_tmp" fi mv "$mon_tmp" "$mon"