Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


The latter part is a timestamp. Is there any way that I can access the directory with the greatest timestamp from zsh?

What would be ideal is if there were a way to configure zsh's tab-completions to find the greatest directory.

share|improve this question
up vote 4 down vote accepted

The sort command should help you with this:

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
share|improve this answer
Exactly what I was looking for. Thanks. :-) – Jason Baker Sep 19 '09 at 14:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.