What is the difference between the where
and which
command in Unix?

- 83,387
- 30
- 160
- 202

- 106
- 2
- 9
-
They both do pretty much the same job (finding executables in the path) but that job really doesn't have anything to do with programming per se :-) – paxdiablo Feb 07 '13 at 13:29
3 Answers
Do you mean whereis? Which just finds the binary, whilst wehereis tries to find the source and manual pages too.

- 108
- 3
"where" does not seem to be a common unix command and I could not find any man page for it.
However, "where" does exist in most Windows OSs.
Looking at the aforementioned link.
WHERE (Windows 2003 + )
Locate and display files in a directory tree.
The WHERE command is roughly equivalent to the UNIX 'which' command.
By default, the search is done in the current directory and in the PATH.
which makes sense since the man page for "which" states:
WHICH(1)
NAME
which - shows the full path of (shell) commands.
Are you using Cygwin?
I ask because this would be the most common case where both "which" and "where" would exist in the same environment.
In that environment, "which" would show where the command is in is path in a unix-like way.
$ which where
/cygdrive/c/Windows/system32/where
and "where" would show the path in a windows like manner.
$ where which
C:\cygwin\bin\which.exe

- 3,092
- 1
- 24
- 46
Disclaimer: This is on a windows box using cygwin.
Which
shows the full path of a one executable Where
can show for multiple.
$which git sh
would produce something like /bin/git/
relative path of the first arg passed but ,
$where git sh
produces the absolute path for all the arguments passed i.e note I'm on a windows box so i get something to the effect of
C:\Program Files (x86)\Git\bin\git.exe
C:\Program Files (x86)\Git\cmd\git.exe
C:\Program Files (x86)\Git\bin\sh.exe
To add to the other answers I think where only exists in windows.

- 11,764
- 4
- 54
- 80