Created
July 22, 2013 10:15
-
-
Save martinseener/6052809 to your computer and use it in GitHub Desktop.
Bash Funcion which returns the oldest file for specified path (recursive)
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
getOldestFile(){ | |
# Returns oldest file in path specified by $1 | |
if [ -z "$1" ]; then | |
echo "No Path argument given - exiting." | |
exit 1 | |
fi | |
find $1 -type f -printf '%T+ %p\n' | sort | head -1 | cut -d' ' -f2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment