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
Here's a function you can put in your bashrc file:
function command-search { oldIFS=${IFS} IFS=":" for p in ${PATH} do ls $p | grep $1 done export IFS=${oldIFS} }
Example usage:
$ command-search gnome gnome-audio-profiles-properties* gnome-eject@ gnome-keyring* gnome-keyring-daemon* gnome-mount* gnome-open* gnome-sound-recorder* gnome-text-editor@ gnome-umount@ gnome-volume-control* polkit-gnome-authorization* vim.gnome* $
FYI: IFS is a variable that bash uses to split strings.
Certainly there could be some better ways to do this.
in debian: ls /bin/ | grep "whatImSearchingFor"
compgen -c > list.txt && wc list.txt
You can always to the following:
1. Hold the $PATH environment variable value.
2. Split by ":"
3. For earch entry:
ls * $entry
4. grep your command in that output.
The shell will execute command only if they are listed in the path env var anyway.
Why don't you just type:
seachstr
In the terminal.
The shell will say somehing like
seacrhstr: command not found
EDIT:
Ok, I take the downvote, because the answer is stupid, I just want to know: What's wrong with this answer!!! The asker said:
and see if a command is available.
Typing the command will tell you if it is available!.
Probably he/she meant "with out executing the command" or "to include it in a script" but I cannot read his mind ( is not that I can't regularly it is just that he's wearing a mind reading deflector )
For Mac users (find doesn't have -executable and xargs doesn't have -d):
echo $PATH | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -perm '++x'