From 3e1f4afb8969fd7e95718401f1661259c1031bde Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 1 Feb 2019 14:49:15 -0600 Subject: [PATCH] Add List The Stack Of Remembered Directories as a unix til --- README.md | 3 ++- ...ist-the-stack-of-remembered-directories.md | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 unix/list-the-stack-of-remembered-directories.md diff --git a/README.md b/README.md index fe77a80..a6adbff 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_753 TILs and counting..._ +_754 TILs and counting..._ --- @@ -701,6 +701,7 @@ _753 TILs and counting..._ - [List Parent pid With ps](unix/list-parent-pid-with-ps.md) - [List Stats For A File](unix/list-stats-for-a-file.md) - [List The Available JDKs](unix/list-the-available-jdks.md) +- [List The Stack Of Remembered Directories](unix/list-the-stack-of-remembered-directories.md) - [Map A Domain To localhost](unix/map-a-domain-to-localhost.md) - [Only Show The Matches](unix/only-show-the-matches.md) - [Open The Current Command In An Editor](unix/open-the-current-command-in-an-editor.md) diff --git a/unix/list-the-stack-of-remembered-directories.md b/unix/list-the-stack-of-remembered-directories.md new file mode 100644 index 0000000..55f832f --- /dev/null +++ b/unix/list-the-stack-of-remembered-directories.md @@ -0,0 +1,23 @@ +# List The Stack Of Remembered Directories + +When you open a new Unix shell, you start in some directory, probably your +home (`~/`) directory. As you `cd` around to different directories, there is +a paper trail of your movements, a listing of where you've been. You can +view this listing of directories with the `dirs` command. + +``` +$ dirs +~/ +$ cd code +$ dirs +~/code ~/ +$ cd /usr/bin +$ dirs +/usr/bin ~/code ~/ +``` + +Each time you `cd`, the directory you have moved to is pushed onto the stack of +visited directories. Alternatively, you can use the `popd` command to return +to the previous directory, removing the current directory from the stack. + +[source](http://www.gnu.org/software/bash/manual/html_node/Directory-Stack-Builtins.html#Directory-Stack-Builtins)