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

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

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

The post Get the name of the newest file in a directory on the linux shell appeared first on FAQforge.

Sponsored


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

See also  How to Install and Setup OneDrive Client in Ubuntu 22.04

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply