]> code.delx.au - mediapc-tools/blobdiff - monitor-dir
mediapc-utils: simplify volume control
[mediapc-tools] / monitor-dir
index 5277f56f443acd4f337f0f87e50211998661b79e..baf02e44a5b32eb024ddd7df9ecde4b66d7d1bf4 100755 (executable)
@@ -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] [ls-options]"
-       exit 1
+    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"