The command takes one or more arguments; for each of these arguments, it prints the full path of the executable to stdout that would have been executed if this argument had been entered into the shell. It does this by searching for an executable or script in the directories listed in the environment variable PATH. The which command is part of most Unix-like computers. It is also part of the C Shell.5
A which command first appeared in 3BSD.6
Carlo Wood developed the GNU implementation used in most Linux-based operating systems.7
On FreeBSD, the which utility was originally written in Perl by Wolfram Schneider. The current version of which was rewritten by Daniel Papasian using the C programming language.8
Multics uses the command where abbreviated as wh.
The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project9 and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.10 Windows also includes the similar where.exe command.
The same functionality is available in MS-DOS, but not Windows, as the built-in TRUENAME command.
In PowerShell, the functionality is provided by the Get-Command Cmdlet.11
The FreeDOS version was developed by Trane Francks.12
The command is used to find and print the location of a specific program.13
Inputs:
"AROS Research Operating System". http://aros.sourceforge.net/documentation/users/shell/index.php ↩
"FreeDOS 1.2 Updates Group - Utilities". Ibiblio.org. Retrieved 2022-09-08. http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html ↩
which for Windows from the GnuWin32 project http://gnuwin32.sourceforge.net/packages/which.htm ↩
"Command", The Open group base specification, Issue 7, IEEE std 1003.1-2008 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html ↩
which(1) – OpenBSD General Commands Manual https://man.openbsd.org/which.1 ↩
which(1) – Linux User Commands Manual https://linux.die.net/man/1/which ↩
which(1) – FreeBSD General Commands Manual https://www.freebsd.org/cgi/man.cgi?query=which&sektion=1 ↩
"Native Win32 ports of some GNU utilities". Unxutils.sourceforge.net. Retrieved 2022-09-08. http://unxutils.sourceforge.net/ ↩
"Get-Command (Microsoft.PowerShell.Core) - PowerShell". https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/get-command?view=powershell-3.0 ↩
"FreeDOS 1.2 Updates Package - which (Unix-like)". Ibiblio.org. 2002-03-20. Retrieved 2022-09-08. http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/which.html ↩
"AROS Research Operating System". http://aros.sourceforge.net/documentation/users/shell/which.php ↩