Skip to content

Instantly share code, notes, and snippets.

@luiscape
Created June 27, 2016 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luiscape/b34f414b50974c8acfc38e76944ee3d2 to your computer and use it in GitHub Desktop.
Save luiscape/b34f414b50974c8acfc38e76944ee3d2 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# The following script finds the
# latest (edited or created) 10 files
# on a Linux system. It runs quite
# quickly.
#
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
#
# The same command above can be turned into
# a simple function, as follows:
#
function find_latest() {
if [ -z "$1" ]
then
echo "No path provided, using local path."
PATH = .
else
PATH = $1
fi
if [ -z "$2" ]
then
LINES = 10
else
LINES = $2
fi
find $PATH -type f -printf "%C@ %p\n" | sort -rn | head -n $LINES
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment