Created
June 27, 2016 14:52
-
-
Save luiscape/b34f414b50974c8acfc38e76944ee3d2 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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