Skip to Main Content
Linux Desktop Hacks
book

Linux Desktop Hacks

by Nicholas Petreley, Jono Bacon
March 2005
Beginner to intermediate content levelBeginner to intermediate
342 pages
15h 55m
English
O'Reilly Media, Inc.
Content preview from Linux Desktop Hacks
Simplify Changing Directories #14
Chapter 2, Console
|
47
HACK
Assuming you have defined CDPATH as shown in the previous example, now
you should be able to type this command, (almost) no matter what your cur-
rent directory might be:
$ cd chapter2
The command should take you immediately to the directory /docs/pub/
books/oreilly/linuxhacks/chapter2.
The Catch
Remember I said you’re obsessive about organization? Suppose you also cre-
ated the following directories according to the same pattern mentioned earlier:
/docs/pub/books/oreilly/bsdhacks/chapter1
/docs/pub/books/oreilly/bsdhacks/chapter2
/docs/pub/books/oreilly/bsdhacks/chapter3
Naturally, you have to add a new path to your
CDPATH environment variable:
$ export CDPATH=:.:/docs/pub/books/oreilly/linuxhacks:/docs/pub/books/
oreilly/bsdhacks
As with the PATH environment variable, you separate different search paths
with a colon. The system searches through each path from left to right. Now
issue this command:
$ cd chapter2
Where do you think it takes you? It puts you in the same place as before, /docs/
pub/books/oreilly/linuxhacks/chapter2.Thatisnot what you expected or
desired. But it happened because the
cd command searches the CDPATH envi-
ronment variable paths from left to right. It searched the linuxhacks location
first and found chapter2. So, that’s where it assumed you wanted to go.
The Solution
One solution is to avoid being obsessive about standardizing ...
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

Linux Server Hacks, Volume Two

Linux Server Hacks, Volume Two

William von Hagen, Brian K. Jones
Introducing Linux Distros

Introducing Linux Distros

Jose Dieguez Castro

Publisher Resources

ISBN: 0596009119Supplemental ContentCatalog PageErrata