7

I would like to use the recently accessed directories list for logging purposes.

Is the directory stack as used by pushd and popd stored somewhere, perhaps as a list of folders in a text file? If so, where?

OJFord
  • 1,838
  • 1
  • 16
  • 26
B.Kocis
  • 227
  • 1
  • 6

3 Answers3

8

dirs

is the shell builtin you're looking for, see the man page for bash's implementation:

Display the list of currently remembered directories.

Syntax

dirs [+N | -N] [-clpv]

OJFord
  • 1,838
  • 1
  • 16
  • 26
2

it could be in...

printf %s\\n "${DIRSTACK[@]}" >this_text_file
mikeserv
  • 57,448
  • 9
  • 113
  • 229
1

No, it's just in memory. the source code lies in bash-4.4/builtins/pushd.def: popd_builtin

oxnz
  • 671
  • 6
  • 4