which

Locate a program file (UNIX)

Syntax:

which [-afLls] program...

Runs on:

Neutrino

Options:

-a
Find all occurrences of program in PATH.
-f
Display the full pathname.
-L
Display the long format (as in ls -l) for each program found, displaying link information if the file is a symlink.
-l
(“el”) Display the long format (as in ls -l) for each program found.
-s
Search for shared objects in the directories identified by the LD_LIBRARY_PATH environment variable and the _CS_LIBPATH configuration string.

Description:

The which utility searches for the specified programs. By default, which searches the directories listed by your PATH environment variable, but if you specify the -s option, it searches the directories specified by LD_LIBRARY_PATH and _CS_LIBPATH.

Examples:

Display the full pathname and long status for all versions of the ls utility found in PATH:

which -alf ls

Display the pathname for the which utility:

which which

Locate the devg-flat.so shared object:

which -s devg-flat.so

Environment variables:

PATH
A colon-separated list of directories to search for executables.
LD_LIBRARY_PATH
A colon-separated list of directories to search for shared libraries.

Exit status:

0
All input files were found.
>0
An error occurred.

See also:

ls, whence (builtin ksh command)