bash alias to get latest/most recent file
Command
$ alias latest="find . | sort | tail -n 1"
This allows you to have an alias to get file name of most recently modified file in the current directory. Save in your .bashrc
or .aliases
file.
Usage
$ vi `latest`
Opens most recently modified file in vim
$ open `latest`
If in pictures directory, will open your most recently modified photo in image preview (in OSX)
Written by Ryan Regalado
Related protips
2 Responses
There's a missing parameter to find?
over 1 year ago
·
You're right @redolent, I will update so it read find . -d 1 | sort | tail -n 1
so it doesn't descend so many levels deep and only sorts on current directory. Good catch!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Aliases
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#