#!/bin/sh set -e #do the files exists? if [ ! -f "$1.new" ]; then exit 0; fi #do the original file exists? if [ ! -f "$1" ] then mv $1.new $1 exit 0 fi #they do, compare them, but ignore the line with if diff -I "Last modified:.*" $1.new $1 > /dev/null then #they are the same - choose the old one, but set actual timestamp rm -f $1.new touch $1 else #they differ mv -f $1.new $1 fi