Word Completion

If you’ve been following along the past week or so, you’ve seen that Linux commands can add up to a lot of typing. What with all the options available for each command, life in the console window could easily be a quick trip up carpal tunnel lane.

Linux provides a way to circumvent that wrist and finger irritation in the form of word completion. In short, Linux is capable of finishing what you start when typing a command in a console screen. The secret to word completion in Linux is a concept called “minimal completion.” In other words, you need only type enough of a command or file name to distinguish it from other files in a directory. The magic key to word completion? The tab key. Here’s an example.

You type:    /usr/lo [tab]
You get:      /usr/local/

You type:    /home/t [tab]
You get:      /home/tony/

Once the shell works its word completion hoodoo, all you need to do is press enter to move to the directory or execute the command.

Another interesting feature of word completion in the bash shell is the ability to list all files with a spelling similar to what you’ve typed. Again, the magic lies in the tab key. For this list, simply press the tab key twice. Here’s an example:

You type:    /usr/l [tab] [tab]
You get:      lib    local

Tabbing twice lists all the subdirectories of /usr that begin with the letter l.

See? Linux can even save you from repetitive stress disorder.