Skip to content

Instantly share code, notes, and snippets.

@martinseener
Created July 22, 2013 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martinseener/6052809 to your computer and use it in GitHub Desktop.
Save martinseener/6052809 to your computer and use it in GitHub Desktop.
Bash Funcion which returns the oldest file for specified path (recursive)
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