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 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 At IU, how do I get support for Linux or Unix?

This is document aids in the Knowledge Base.
Last modified on 2017-05-16 11:53:18.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.