#!/bin/sh # aget [URL] - like wget, but archive the results url=$1 base=${url##*/} date="$(date -I)" out="$base-$date" for f in "$base-"????-??-??; do [ "$f" != "$out" ] && last=$f done wget -O "$out" "$url" if ! [ -f "$last" ] || ! cmp "$last" "$out"; then echo "new $out" [ -x "$last" ] && chmod +x "$out" [ -h "$base" ] && ln -sf "$out" "$base" else echo unmodified rm "$out" false fi