Home » Questions » Computers [ Ask a new question ]

How do I access a directory with the most recent timestamp in its name?

How do I access a directory with the most recent timestamp in its name?

I have a set of directories on my linux box that have names like this:

Asked by: Guest | Views: 344
Total answers/comments: 1
bert [Entry]

"The sort command should help you with this: http://www.computerhope.com/unix/usort.htm

depending on if you do a regular sort or reverse sort, the directory with the highest timestamp could be at the top or bottom. Check the output first, then you can use the head or tail linux command to take the top or bottom entry (example: head -n 1) then pass it to xargs with the cd command. An example is like this:

ls | sort | head -n 1 | xargs cd"