5

In a Windows Command Prompt, I can find the location of things like Java and GIT by using the where command.

For example, typing where java yields C:\Program Files\Java\jdk1.8.0_05.

What is the macOS Terminal equivalent for the Windows Command Prompt command, where?

10

The macOS Terminal equivalent of the Windows Command Prompt command where is which.

Typing which java in my macOS Terminal yields /usr/bin/java, and which git yields /usr/bin/git.

  • Depending on the shell that you use then other shell builtin commands such as type, command, or whence could be used. – fd0 Feb 12 '17 at 11:19
10

The which command prints the most precedent application on the PATH whereas where prints all matching applications on the path.

The difference manifests when you have side by side instances of an application installed and all set on the path. Strictly speaking which by itself returns the instance resolved first on the path left to right, where returns ALL found instances on the path resolved left to right. If you want to see what I'm talking about, on a Windows 7 or above system type:

where notepad you may see two paths returned

C:\>where notepad 
C:\Windows\System32\notepad.exe
C:\Windows\notepad.exe

The real equivalence is

which -a someApp === where someApp

  • How is this any different that the answer that was already posted? – Allan Apr 12 '18 at 1:41
  • 4
    The difference manifests when you have side by side instances of an application installed and all set on the path. Strictly speaking which by itself returns the instance resolved first on the path left to right, where returns ALL found instances on the path resolved left to right. If you want to see what I'm talking about on a Windows 7 system if you type where notepad you may see two paths returned C:\>where notepad C:\Windows\System32\notepad.exe C:\Windows\notepad.exe – jxramos Apr 12 '18 at 2:24
  • @jxramos That's actually very useful to know. Thanks! :) – James Dunn Apr 12 '18 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .