which Command

Purpose

Locates a program file, including aliases and paths.

Syntax

whichName ... ]

Description

The which command takes a list of program names and looks for the files that run when these names are given as commands. The which command expands each argument, if it is aliased, and searches for it along the user's path. The aliases and paths are taken from the .cshrc file in the user's home directory. If the .cshrc file does not exist, or if the path is not defined in the .cshrc file, the which command uses the path that is defined in the user environment.

A diagnostic occurs if the name refers to multiple words or if no executable file with the argument name is found in the path.

In the Korn shell, you can use the which command to produce a more verbose report.

Examples

To find the executable file associated with a command name of lookup, enter the following command:

which lookup

Files

Table 1. Files
Item Description
$HOME/.cshrc Contains the source of aliases and path values.