OpenBSD manual page server

Manual Page Search Parameters

WHICH(1) General Commands Manual WHICH(1)

whichlocate a program file (or files) in the path

which [-a] name ...

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.

The following environment variables affect the execution of which:

A colon-separated list of directories in which to find executables. If PATH is not set or is empty, which will use the system's default search path.

The which utility exits with one of the following values:

0
All names were successfully resolved.
1
Some names were resolved but not all.
2
No names were resolved.

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

csh(1), find(1), locate(1), whereis(1), environ(7)

which also exists as a built-in to csh(1), though with a different syntax.

A which command first appeared in 3.0BSD.

The -a option first appeared in OpenBSD 2.3.

January 14, 2016 OpenBSD-7.0