commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
reverse the sorting of ls to get the newest file:
ls -1tr --group-directories-first /path/to/dir/ | tail -n 1
If there are no files in the directory you will get a directory or nothing.
There are 2 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.