Last active
January 2, 2016 15:39
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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