8.13. The Directory StackThe C shell allows you to create and manipulate a directory stack, which makes life a little easier when you're flipping back and forth between a small working set of directories. To push a directory onto the directory stack, use the pushd command (Figure 8-40).
To pop a directory from the directory stack, use the popd command (Figure 8-41).
The dirs command (Figure 8-42) lets you see the contents of the directory stack.
Here are some examples of directory stack manipulation: % pwd ...I'm in my home directory. /home/glass % pushd / ...go to root directory, push home dir. / ~ ...displays directory stack automatically. 8.13.1. The Hash TableAs described in Chapter 5, "The Linux Shells," the PATH variable is used when searching for an executable file. To speed up this process, the C shell stores an internal data structure, called a hash table, that allows the directory hierarchy to be searched more quickly. The hash table is constructed automatically whenever the ".tcshrc" file is read. In order for the hash table to work correctly, however, it must be reconstructed whenever $PATH is changed, or whenever a new executable file is added to any directory in the $PATH sequence. The C shell takes care of the first case automatically, but you must take care of the second. If you add or rename an executable in any of the directories in the $PATH sequence except your current directory, you should use the rehash command to instruct the C shell to reconstruct the hash table. If you wish, you may use the unhash command to disable the hash table facility, thereby slowing down the search process. Figure 8-43 describes how these shell commands work.
In the following example, I added a new executable into the directory "~/bin", which was in my search path. The shell couldn't find it until I performed a rehash. % pwd ...I'm in my home directory. /home/glass % echo $PATH ...list my PATH variable. .:/home/glass/bin:/usr/bin:/usr/local/bin:/bin: % cat > bin/script.csh ...create a new script. |