Is there a Linux command that will list all available commands and aliases for this terminal session?
As if you typed 'a' and pressed tab, but for every letter of the alphabet. Or running 'alias' but also returning commands.
Why? I'd like to run the following and see if a command is available:
ListAllCommands | grep searchstr
Use "which searchstr". Returns either the path of the binary or the alias setup if it's an alias
Edit: If you're looking for a list of aliases, you can use:
Add that in to whichever PATH searching answer you like. Assumes you're using bash..
Here's a solution that gives you a list of all executables and aliases. It's also portable to systems without
xargs -d
(e.g. Mac OS X), and properly handles paths with spaces in them.Usage:
myscript.sh [grep-options] pattern
, e.g. to find all commands that begin withls
, case-insensitive, do: