I installed a program (iftop) on Debian Squeeze but some days ago I forgot it's name. I had only this information about the program:

1) It was called *top

2) I could find it using bash-completions.

I wanted to grep all the options of bash-completion. Do you have any idea on how can I do it?

  • Not an answer to the question, but an alternative solution: 1) locate top (long list of all installed files with top in their filename). 2) find /path/to/search -name "*top" -print. (same, but searches the disk while locate uses a database). – Hennes Mar 25 '13 at 14:40
  • 2
    locate is a very bad choice. It might not necessarily be up to date and it matches all files, not only executables. The find solution is better, but you need to add something like -perm /+x to match only executables. – Marco Mar 25 '13 at 14:46
  • @Hennes: It would be nice with longer words, but with "*top" it prints too much possibilities. – Blex Mar 25 '13 at 14:48

Use the compgen builtin to get a list of possible completions:

compgen -c | grep top

You can request completions for various types of completion actions like commands, aliases, functions..., e.g. -c is equivalent to -A commands. See man bash for more details.


Using compgen is definitely a nice one. Alternatively, and that would work with any POSIX shell, you could check the commands in $PATH with:

(IFS=:; set -f; ls -- $PATH | grep top$)

With zsh:

type -m '*top'

You can also query the whatis database:

man -ks1:8 top$

While you can figure it out from the completion system, this isn't the most obvious method.

Almost all programs installed by pacakges are in /usr/bin, so you can list the programs in /usr/bin whose name ends with top:

echo /usr/bin/*top

You can list the files by inode change time. The modification time of an installed program is usually the time it was compiled, because archiving and installation tools copy the modification time alongside the data. But the inode change time of a file is the last time anything happened to it, including being extracted or copied (in fact, it's having its modification time changed that resets the inode change time). Since you installed the program recently, it's one of the last ones shown by the following command:

ls -lctr /usr/bin/*top

Remove the r option if you want to start looking from the top rather than from the bottom.

You could also look at the log of programs you installed. They're in /var/log/history.log.


You could use a shell function which searches your PATH and known directories that contain binaries, but that are not in your PATH. Example:

findprogram() {
  ls $(echo $PATH:/sbin:/usr/sbin | sed "s/:/\ /g") | grep "$1" | sort --unique


findprogram top

This outputs a sorted list of candidates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.