This morning I wanted to find the latest files I modifed in a directory. My first thought was to use ls -l then pipe that to awk or sort, in short I was going in a very convoluted direction (probably cuz I write Java for a living) 🙂

My second thought was I bet ls can already get me there. I was close, ls got me most of the way, a pipe to head got me the files/directories I wanted:

ls -ct1 | head -10

One thought on “latest modified file using ls

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s