which, whereis

display full path name for executable command 

Command


SYNOPSIS

which [-a] [-p path] command ...

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 7/2008R2/8/2012/10/2016, 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 -a with the exception that the -p path option is not available.

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 7/2008R2/8/2012/10/2016'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:

— an appropriate executable file cannot be found
— invalid command line option


PORTABILITY

Available on some UNIX systems. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.


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

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Integrity


SEE ALSO

Commands:
command, sh, whence


PTC MKS Toolkit 10.1 Documentation Build 15.