X-Git-Url: https://code.delx.au/mediapc-tools/blobdiff_plain/e806cbb8adfd91c7935989e8ba0fa1ba22e24f77..5d18bd54fd59cfb670fe2d14dc00890e4e339d81:/monitor-dir diff --git a/monitor-dir b/monitor-dir index ba220b1..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 -tlR "$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"