Skip to Content
Small, Sharp Software Tools
book

Small, Sharp Software Tools

by Brian P. Hogan
June 2019
Intermediate to advanced
328 pages
7h 27m
English
Pragmatic Bookshelf
Content preview from Small, Sharp Software Tools

Switching Between Directories

In the last few examples, you moved between the /var and /usr/bin directories by specifying either relative or absolute paths. Switching back and forth between two directories is something you’ll do more often than you’d think. This has a nice shortcut command. Whenever you change to a new working directory, your shell stores the previous directory.

To switch back to the previous directory, use cd -. This command retrieves the value of the previous directory and uses it to change the directory.

Try this exercise out. First, go to your home directory. Then, navigate to the /var directory. Use cd - to switch back and forth between the two:

 $ ​​cd
 $ ​​cd​​ ​​/var
 $ ​​cd​​ ​​-
 /home/brian
 $ ​​cd​​ ​​-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The VimL Primer

The VimL Primer

Benjamin Klein
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781680507003Errata Page