15 lines
306 B
Bash
Executable file
15 lines
306 B
Bash
Executable file
#!/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 "$input" > "$output"
|
|
fi
|