In Unix, how do I use filename completion?
Filename completion is a feature built into some Unix
shells that allows you to type part of a filename or
directory name and press a key to fill out the rest. In most shells,
you can type only enough of the file's name to make it unique, and
then press the Esc key to fill in the rest. Note the
following:
- This doesn't work in the
shshell.
- In
csh, to turn on filename completion, enterset filec.
- In the
tcshorbashshell, press theTabkey instead ofEscto complete a filename.
For example, let's say you have the following files and subdirectories in your current directory:
./ .newsrc bin/ ../ .pinerc dead.article .cshrc .plan dead.letter .emacs Mail/ lynx_bookmarks.html .login News/ www/
To enter your bin subdirectory, you could type cd
b , and then press the Esc key. The shell
would complete the name, and you would see cd bin/.
Sometimes the shell will do a partial completion. The shell will fill
in characters until it has to choose between two or more
files. Continuing the example above, if you type more d
and then press Esc, the shell will fill in only to
more dead. , at which point you'll have to enter the
next character of the file you want. This is because both
dead.article and dead.letter start with a
"d"; beyond dead. , the shell can't tell which file
you want. Likewise, if you type emacs .p and then press
Esc, the shell will not be able to fill in any more
characters because the files .plan and
.pinerc both begin with "p".
At Indiana University, to get support for personal or departmental Linux or Unix systems, see At IU, how do I get support for Linux or Unix?
Also see:
- In Unix, where can I get information on differences between the various shells?
- What is a wildcard, and how can I use it?
- In Unix, what is chsh, and how do I use it to change my shell?
Last modified on August 22, 2008.






