WHICH(1)

NAME
which - locate a program file (or files) in the path

SYNOPSIS
which [-a] [name] ...

DESCRIPTION
Which takes a list of names and looks for the files which would be executed had these names been given as commands. Each argument is searched for along the user's path.

If the -a flag is given, which will return a list of all matches instead of just the first match.

RETURN VALUES
The which utility exits with one of the following values:

0   All names got successfully resolved.

1   Some names got resolved but not all.

2   No names got resolved.

-1  A system error occurred.

DIAGNOSTICS
A diagnostic is given if an executable file with the argument name was not found in the path.

ENVIRONMENT VARIABLES

PATH
    which uses the environment variable PATH as a colon-separated list of directories in which to find executables. If PATH is not set, and the given name is not a fully-qualified or relative pathname, which will fail.

CAVEATS
The which command formerly was a csh(1) script and could expand aliases. csh(1) now has a built-in which comand so this version is intended for use with other shells like sh(1).

SEE ALSO
csh(1), sh(1), whereis(1), environ(7)

HISTORY
A which command appeared in 3.0BSD.