Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

Using Completion in the bash Shell

One of the cool features of the bash shell is command argument completion, with which you can type just part of a command, press tab.jpg, and have bash complete the command for you (Code Listing 3.8).

Code Listing 3.8. In this example, we typed only the ls command followed by "cd pub" and pressed the key; bash completed the command for us.

bash-2.00$ ls
Complete NewProject bogus2
→ ftp   puppy
Completed    News   dead.letter
→ mail  temp
Mail access   files
 → public_html  testme
bash-2.00$ cd public_html/
bash-2.00$

To use completion in the bash shell:

  1. ls -l

    Use ls -l to list the files in your current directory.

  2. cd pub tab.jpg

    Type in a partial command, then press tab.jpg to complete the command. In this example, we typed the cd command and part of the public_html directory (truncated to pub in the example), then pressed tab.jpg to complete it (see Code Listing 3.8).

  • + Share This
  • 🔖 Save To Your Account