From: James Bunton Date: Mon, 15 Oct 2012 08:29:59 +0000 (+1100) Subject: monitor_dir: more options & only display diff X-Git-Url: https://code.delx.au/monosys/commitdiff_plain/98819f3cc36ad0fe1083e445e1e9a162a306e55c monitor_dir: more options & only display diff --- diff --git a/bin/monitor_dir b/bin/monitor_dir index ba220b1..5277f56 100755 --- a/bin/monitor_dir +++ b/bin/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"