Use tab to auto complete commands in the command line

Use tab to auto complete commands in the command line

Updated: 04/26/2017 by Computer Hope
auto complete dos tipWhen at the MS-DOS, Windows command line, or a Linux or Unix shell typing in long file names or directories can become a burden. Use the tab keyto auto complete the names of directories and files while in the command line. Below, are a few examples of how this can be done.

MS-DOS and Windows command line users

While at the prompt, typing in one or more letters a file or directory name contains will auto complete the name in alphabetical order. For example, when at the C:\> prompt type the below command.
cd p
After the above command has been typed, instead of pressing the enter press the tab key. When you press the tab key the first directory that begins with p will be automatically typed into the command. Continuing to press the tab key will cycle through all available directories including the "Program Files" directory. This shortcut can be used any time you need to type a file name or directory in a command.
Tip: If you type one or more beginning letters for a file name or directory that does not exist in the current directory, the tab key will not auto complete.

Most Linux and Unix users

Depending on your variant of Linux or Unix and if you're remotely connecting to a Linux box can change how the tab key is used for auto complete. However, below is a general run down on how this is commonly used in Linux. At the prompt in your home directory type the below command.
cd p
Assuming your home directory has "public_ftp", "public_html", or another file or directory that begins with 'p' you are shown all available files and directories. If you continue to type the next letter available, for example, "cd pu" the command will complete the remaining of the file name or directory up to the point there is no conflict. If you had both directories mentioned earlier in the current directory, it would auto complete up to "public_" because there are two directories beginning with "public_". Pressing the tab key again shows you the remaining available files beginning with "public_". If you wanted to type "public_html", add a 'h' and then press tab to complete the directory name.

Comments

Popular posts from this blog

Typing Tricks