0

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

bulk-load_20090918-162100

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.

1 Answer 1

4

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
1
  • Exactly what I was looking for. Thanks. :-) Sep 19, 2009 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .