cmd equivalent of linux 'which' command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
Does anyone know of a DOS or cmd.exe equivalent to the Linux 'which'
command. On Linux, 'which' gives me the full path of an executable. So for
example, if I have multiple versions of java.exe, running 'which java.exe'
gives me the full path of the one that will run based on PATH settings.
Thanks.
 
Martin O said:
Hi All,
Does anyone know of a DOS or cmd.exe equivalent to the Linux 'which'
command. On Linux, 'which' gives me the full path of an executable. So for
example, if I have multiple versions of java.exe, running 'which java.exe'
gives me the full path of the one that will run based on PATH settings.
Thanks.

Although this MS NG but here it goes:
Use the Bash command (is the default command in linux);
builtin = for the built-in shell
bash = run the bash shell
ksh = run the korn shell
sh = run the bourne shell
csh = run the c shell which is /C

also the /bin command
sudo to install an application.

Here is a link will explain for you more:
www.yolinux.com/TUTORIALS/unix_for_dos_users.html

HTH.
nass
 
nass said:
Hmm,Well the link Provide both if you did read.
Yes indeed. A more direct answer is "set path". As it is documented, this
command displays the contents of the Path environment variable.
The program in question is somewhere in one of the folders in the Path.
Jim
 
Thanks for the replies guys.

I checked that link nass. I couldnt find anything about an equivalent to the
linux 'which' command. There is another variation of this command on other
flavors of unix...I think its 'file' if I remember correctly. I found
mentions of a dos command 'truename' I think it was. But this is not in XP.

Thanks for pointing out that I can view the contents of the PATH variable
Jim. I suppose if I had to, I could check each folder in my path for the
executable I'm looking for, then I could assume that the OS is executing the
first one I found. I was actually hoping for something easy like the linux
'which' command though. For example, in linux, if I have different java
executables, I could quickly find out which one runs when I type just 'java'
by entering the command 'which java'. The result would be something like
'/usr/bin/java'. It would take into acount what my current directory is, and
the path, and give me *exactly which* java it would run. Useful for
sanity-checks.

At any rate, I've found a solution I should have thought of before: cygwin.
But I'd still be interested in finding out if theres an 'xp command line' way.

Thanks again.
 
Back
Top