File name completion is used when you are typing commands with long file names . Using this feature of the shell, you type in a few starting characters of the name of a file and then press the key twice, and the shell completes the name of the file. Consider a directory that contains three files, and you want to see the contents of a file beta .
$ ls alpha-334 alpha-434 beta $ cat b Esc Esc $ cat beta
As soon as you press the key twice, the shell completes the file name as shown in the last line.
If there is more than one file that starts with the same characters you have typed, the shell completes the file name to the extent that all files have the same characters. After that you can press the and keys to list the available choices and then complete the file name by typing additional characters. Please see the next example where two files start with the letter a . By pressing the key twice, the shell completes the file name up to alpha- . After that you can press the keys to see the choices, and then complete the command using the usual command line editing method or by typing additional characters and again pressing the key twice.
$ ls alpha334 alpha-434 beta $ cat a Esc Esc $ cat alpha- Esc = 1) alpha-334 2) alpha-434 $
After displaying the matching files, you can type a few more characters on the command line to distinguish files and again press the key twice to complete the file name.
The file name completion mechanism may be very useful when typing long commands with less keystrokes and without any error.
Top |