Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active January 2, 2016 15:39
Show Gist options
  • Save coderofsalvation/8324557 to your computer and use it in GitHub Desktop.
Save coderofsalvation/8324557 to your computer and use it in GitHub Desktop.
compare the dates of two files, return true (0) if file1 has been modified more recently otherwise 1
# compare the dates of two files, return true (0) if file1 has
# been modified more recently otherwise 1
# @param string file1
# @param string file2
function is_newer()
{
[ $# -ne 2 ] && return 1
if [ ! -f $1 ] || [ ! -f $2 ]; then
return 1 # No
fi
if [ -n "$(find $1 -newer $2 -print)" ]; then
return 0 # Yes
else
return 1 # No
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment