Shell autocompletion
If you’re in an interactive shell session (i.e., not executing from a script or creating a Dockerfile), you can use shell autocompletion, also known as tab-completion, to construct commands with fewer keystrokes and a lower chance of typos.
To make use of shell autocompletion, start typing a file or directory name and press Tab. The shell will progressively narrow your choices, displaying possible matches below the line you’re typing on. When there’s only one choice left based on what you’ve typed, the shell will autocomplete that command or argument and you can press Enter. Let’s walk through an example.
If you’re sitting in your home directory on a Linux desktop system, the view might look like this:
~ pwd
/home/dave
~ ls
Desktop
Documents
Downloads
Library
Movies
Music
Pictures
Public
code
go
If you want to move to the Documents
directory, you’ll use the cd
(change directory) command to do...