If you have a directory with many files (a few thousand in my case) and need to know which one is the newest, then the following command might be useful. It returns the name and details of the newest file in a directory where it is executed:

ls -tl | sed -n 2p

Get the name of the newest file in a directory on the linux shell
Tagged on:         

5 thoughts on “Get the name of the newest file in a directory on the linux shell

Leave a Reply

Your email address will not be published. Required fields are marked *

*