#!/bin/bash # Takes input from standard input and overwrites output argument file only if # they differ input="$(cat)" output="$1" new="$(sha256sum <<<"$input" | cut -d " " -f 1)" old="$(sha256sum "$output" 2>/dev/null | cut -d " " -f 1)" if [ "$new" != "$old" ]; then echo -n "$input" > "$output" fi