Use filename completion in Unix

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 sh shell.
  • In csh, to turn on filename completion, enter set filec.
  • In the tcsh or bash shell, press the Tab key instead of Esc to 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, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

Related documents

This is document aids in the Knowledge Base.
Last modified on 2019-08-27 08:53:42.