From 0c70baa505663740659407660b24cc65243a9c5b Mon Sep 17 00:00:00 2001 From: James Bunton Date: Mon, 15 Oct 2012 19:29:59 +1100 Subject: [PATCH] monitor_dir: more options & only display diff --- monitor-dir | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor-dir b/monitor-dir index ba220b1..5277f56 100755 --- a/monitor-dir +++ b/monitor-dir @@ -4,15 +4,15 @@ # */5 * * * * $HOME/bin/monitor_dir /path/to/something if [ -z "$1" ]; then - echo "Usage $0 dir [monitor_file]" + echo "Usage $0 dir [monitor_file] [ls-options]" exit 1 fi -mon="$1/${2:-.monitor_dir}" +mon="${2:-$1/.monitor_dir}" mon_tmp="${mon}_tmp" -ls -tlR "$1" > "$mon_tmp" +ls "${3:--tlR}" "$1" > "$mon_tmp" if [ -r "$mon" ] && ! cmp -s "$mon" "$mon_tmp" && [ -n "$(ls "$1")" ]; then - cat "$mon_tmp" + diff "$mon" "$mon_tmp" | grep '^> ' | sed 's/^> //' fi mv "$mon_tmp" "$mon" -- 2.39.2