Finishing Names for You
Problem
Some of these path names are pretty long. This is a computer that bash is running on… can’t it help?
Solution
When in doubt, press the Tab key. bash will try to finish the pathname for you. If it does nothing, it may be because there are no matches, or because there is more than one. Press the Tab key a second time and it will list the choices and then repeat the command up to where you stopped typing, so that you can continue. Type a bit more (to disambiguate) then press the Tab key again to have bash finish off the argument for you.
Discussion
bash is even smart enough to limit the selection to certain types of files. If you type “unzip” and then the beginning of a pathname, and then you press the Tab key, it will only finish off with files that end in .zip even if you have other files whose names match as much as you have typed. For example:
$ ls myfile.c myfile.o myfile.zip $ ls -lh myfile<tab><tab> myfile.c myfile.o myfile.zip $ ls -lh myfile.z<tab>ip -rw-r--r-- 1 me mygroup 1.9M 2006-06-06 23:26 myfile.zip $ unzip -l myfile<tab>.zip ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access