This article introduces how to use pattern matching to check if a command exists in Bash, a command line environment for Linux computers and servers.
Question
Is there a command or option that can do pattern matching with commands like which or type that output command paths?
For example, if you want to know mysql-related commands and paths overall, doing which mysql* would give output like:
/usr/bin/mysql_config
/usr/bin/mysql2
Is there a command that can do such things?
Answer
This will work.
compgen -ac | grep mysql
compgen outputs all available commands, and we grep it.