bash operation question

Tim Chase blinux.list at
Sun Jul 19 18:36:33 UTC 2015

On July 19, 2015, Jude DaShiell wrote:
> When using tab completion in bash, sometimes more than a single 
> possibility arises if there are say two or more paths starting out
> with the same prefix.  To select from one of those choces, do I
> need to key in the whole choice from the beginning of the path or
> can I key in enough letters to uniquely identify my choice after
> that list displays?

You only need to type enough to disambiguate it and then hitting
<tab> will complete until the next ambiguity.  So if you have a
directory containing the following three files with date-stamps for
the names:


you can type "2" followed by <tab> and it will complete up to the
month.  You can then type "5" and hit <tab> and it will complete the
last file.  Or instead of "5", you can type "4" and hit <tab>, and it
will complete the "-0" then wait for you to disambiguate with either
"1" or "9", after which you can then hit <tab> again to complete the
rest of the file-name.

Alternatively, you can add the following line to your .bashrc (or just
execute it in a shell to test it out)

  bind "TAB:auto-complete"

which will give the DOS/Windows flavor of completion where hitting
<tab> will complete with the next possible completion-name.  So with
the above files, you'd type "2" followed by <tab> and it would use
"2015-04-01.txt" then you could hit <tab> again and it would change
it to "2015-04-09.txt" and <tab> again for the "2015-05-15.txt" file.

> I tried search inside man bash for list completion and did not find
> this material though a long time ago I was looking for something
> else and stumbled on this material in that man page.

The information is scattered around a bit.  In the bash man-page,
it's in the "READLINE" section under the "Readline Key Bindings"
sub-section.  But it doesn't detail everything, so you have catch
that the "bind" command is a bash built-in, so you then execute

  bind -l

to list all the available bindings.  I don't have a good resource for
detailing all of the available bindings, but the above should at
least get you started.


More information about the Blinux-list mailing list