]> code.delx.au - mediapc-tools/commitdiff
monitor_dir: use comm instead of diff
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 15 Oct 2012 11:10:27 +0000 (22:10 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 15 Oct 2012 11:10:27 +0000 (22:10 +1100)
monitor-dir

index 5277f56f443acd4f337f0f87e50211998661b79e..ce5cd506881d263df3d63c8d5795ea9e7673278e 100755 (executable)
@@ -4,15 +4,15 @@
 #   */5 *   *   *   *     $HOME/bin/monitor_dir /path/to/something
 
 if [ -z "$1" ]; then
-       echo "Usage $0 dir [monitor_file] [ls-options]"
+       echo "Usage $0 dir [monitor_file] [ls]"
        exit 1
 fi
 mon="${2:-$1/.monitor_dir}"
 mon_tmp="${mon}_tmp"
 
-ls "${3:--tlR}" "$1" > "$mon_tmp"
+${3:-ls} "$1" > "$mon_tmp"
 if [ -r "$mon" ] && ! cmp -s "$mon" "$mon_tmp" && [ -n "$(ls "$1")" ]; then
-       diff "$mon" "$mon_tmp" | grep '^> ' | sed 's/^> //'
+       comm -13 "$mon" "$mon_tmp"
 fi
 mv "$mon_tmp" "$mon"