bash: update file if content is different
xxxxxxxxxx
#!/bin/bash
FILE1=/src/path
FILE2=/dst/path
if [ -f "$FILE1" ]; then
if cmp -- "$FILE1" "$FILE2"; then
echo "files already same"
else
echo "update file"
cat $FILE1 > $FILE2
fi
else
echo "$FILE1 does not exist."
fi
bash: update file if content is different