SYNOPSIS
which
[
whereis command ...
DESCRIPTION
Windows systems use the PATH environment variable to determine which directories are searched to find programs. If PATH is not found under Windows NT/2000/XP/2003/Vista/7/2008, which then searches for Path. For each command, which looks through the directories in the search path, and displays the name of the first executable file that matches command.
which uses the PATHEXT environment variable to determine which files are considered executable. As which searches each directory in the search path, it appends each of the extensions in the list, in turn, to command name to see if it matches a file name in that directory. If a match exists, that file is is considered to be executable.
If PATHEXT is not defined, which only considers files with a .exe, .com, .bat, or .cmd extension to be executable.
Because which is intended primarily for use when working from the Windows command prompt, it always searches the current directory first before consulting the search path in the same way that Windows command interpreters (such as cmd.exe) do.
- Note:
-
When running which from the Windows command prompt, not all executable files reported may be directly executable from the prompt. Such files may require the use of an additional program (such as a shell) to execute it. The program to use can normally be determined by the file's extension. For example, files with a .sh extension should be executed using the MKS KornShell.
The whereis command is equivalent to specifying
which
Options
-a -
displays all matching executable files from every directory in Path, not just the first match. This can help you find conflicts between two executables of the same name.
-p path-
searches the path name specified by path instead of the paths indicated by the PATH (or Path) environment variable when looking for matching executable files.
ENVIRONMENT VARIABLES
- PATH
-
contains a list of directories for which to search when looking for command.
- PATHEXT
-
contains a list of file extensions (separated by semicolons) for executable commands. By default, PATHEXT, has the value of Windows NT/2000/XP/2003/Vista/7/2008's PATHEXT variable with .com;.exe;.bat;.sh;.ksh;.csh;.sed;.awk;.pl appended (omitting any extensions already represented in PATHEXT).
DIAGNOSTICS
Possible exit status values are:
- 0
-
An appropriate executable file can be found with the current PATH.
- 1
-
Failure due to any of the following:
PORTABILITY
Available on some UNIX systems. Windows 2000. Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008.
NOTE
This command does not know about shell keywords, aliases, functions, and so forth. For this reason, whence is recommended when you are using the MKS KornShell.
AVAILABILITY
MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
MKS Integrity
SEE ALSO
MKS Toolkit 9.3 Documentation Build 6.