bvvq_q
Last Updated: February 25, 2016
·
2.205K
· design48
3ae6de27bfeb80acbecc2587763750d9

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)

Say Thanks
Respond

2 Responses
Add your response

18653
None

There's a missing parameter to find?

over 1 year ago ·
18654
None

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 ·