O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

which

Synopsis

which [options] [--
] [commands]

List the full pathnames of the files that would be executed if the named commands had been run. which searches the user’s $PATH environment variable.

Options

-a, --all

Print all matches, not just the first.

-i, --read-alias

Read aliases from standard input and write matches to standard output. Useful for using an alias for which.

--read-functions

Read shell functions from standard input and report matches to standard output. Useful for also using a shell function for which itself.

--skip-alias

Ignore --read-alias if present. Useful for finding normal binaries while using --read-alias in an alias for which.

--show-dot

If a matching command is found in a directory that starts with a dot, print ./cmdname instead of the full pathname.

--show-tilde

Print a tilde (˜) to indicate the user’s home directory. Ignored if the user is root.

--skip-dot

Skip directories that start with a dot.

--skip-functions

Ignore --read-functions if present. Useful when searching for normal binaries while using --read-functions in an alias or function for which.

--skip-tilde

Skip directories that start with a tilde (˜) and executables in $HOME.

--tty-only

Stop processing options on the right if not on a terminal.

-v, -V, --version

Print version information and then exit.

--help

Print help information and then exit.

Example

$ which cc ls
/usr/bin/cc
ls:      aliased to ls -sFC

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required