whence
The whence
command line tool is commonly used in Unix-based systems to locate executable files or commands in the shell's search path. It is similar to the which
command but offers some additional functionality.
When you run whence
followed by a command, it reports the location of the command. This is particularly useful when multiple versions of a command are installed and you want to know the exact path of the command you are using.
The output of whence
also includes additional information such as the type of the command (built-in, function, alias, or executable file) and whether the command is hashed (previously looked up and stored for faster future reference).
Additionally, whence
allows you to search for command names that match a given pattern or regular expression, making it helpful for finding commands based on partial names or specific patterns.
In some Unix shells, like zsh, whence
is a built-in command, while in others, it may be an external command provided by the shell's corresponding package.
Overall, whence
is a versatile command line tool that assists users in quickly identifying the location and details of commands within their shell environment.
List of commands for whence:
-
whence:tldr:36813 whence: Display type of {{command}}, with location if defined as a function, or binary (equivalent to the `type` and `command -V` builtins).$ whence -v "${command}"try on your machineexplain this command
-
whence:tldr:653b0 whence: Interpret {{command}}, with expansion if defined as an `alias` (similar to the `command -v` builtin).$ whence "${command}"try on your machineexplain this command
-
whence:tldr:7da99 whence: Search only the `PATH` for {{command}}, ignoring builtins, aliases or shell functions (equivalent to the `where` command).$ whence -p "${command}"try on your machineexplain this command
-
whence:tldr:94f9c whence: Same as above, but show all occurrences on command path (equivalent to the `where` builtin).$ whence -ca "${command}"try on your machineexplain this command
-
whence:tldr:988af whence: Same as above, except display content of shell functions instead of location (equivalent to `which` builtin).$ whence -c "${command}"try on your machineexplain this command