1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/env bash set -eu OUT="$1" shift echo "$@" >"$OUT.tmp" if [ -e "$OUT" ] && cmp -s "$OUT" "$OUT.tmp"; then rm "$OUT.tmp" else mv "$OUT.tmp" "$OUT" fi