3

What is the order for the pathnames of the directories stored in the stack shown by dirs -l?

Are they ordered by their last pushd commands?

Is it possible to order them so that they are ordered by their most recent visit times (a natural extension of $OLDPATH)?

Tim
  • 98,580
  • 191
  • 570
  • 977

1 Answers1

4

It's a stack, with the most-recent cd entry on the left, and the list of pushd directories from the most recent on the left to the oldest on the right (or, with -p, the most recent cd on top and the pushd list from oldest to newest, top-down).

You can reorder the list by editing the values of the $DIRSTACK array variable, but there's currently no built-in mechanism to re-sort the output of dirs.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250