Communities for your favorite technologies. Explore all Collectives
Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Get early access and see previews of new features.
ls -Art | tail -n 1
This will return the latest modified file or directory. Not very elegant, but it works.
Used flags:
-A list all files except . and ..
-A
.
..
-r reverse order while sorting
-r
-t sort by time, newest first
-t
Not very elegant, but it works.
ls -rth | tail -n 1 ? Not very elegant, but it works.
ls -rth | tail -n 1
ls -rth | tail -n 1 ?