Save the list of all available commands in your box to a file

compgen -c | sort -u > commands
When you press TAB twice in your prompt, bash tells you something like "Display all 4567 possibilities? (y or n)" But when you press "y" you only get the list in the terminal output and, if you want to save it to a file, you have to copy it by hand from the vterm screen. With this utility you save the list to a file or pipe it to another command at will You can use the file saved list to grep for a particular pattern, useful if you are searching for a command but you only remember a few letters

By: h3nr1x
2011-06-28 00:29:15

What Others Think

Oh wow. I had totally forgotten about compgen. Thanks!!
kaedenn · 527 weeks and 1 day ago
why not just use Ctrl + R (if you are using bash) instead of saving to a file and looking up? Is there much difference?
sanchan89 · 524 weeks and 5 days ago
To you use Ctrl+r, the command you are looking for have to be in the bash-history, if you haven't typed in yet in the box you are working at or you just used long time ago (and it was dropped from the bash-history), this could be a good way to find it out Also, with the file you can look an overview of the programs available in your system
h3nr1x · 524 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: