DOS equivalent of UNIX 'which'?

March 26, 2009 at 02:08:39
Specs: Windows XP
Is there a DOS/XP equivalent of the UNIX 'which' command? I've found several lists of DOS/UNIX equivalent commands, but which is never among them.

See More: DOS equivalent of UNIX which?

Report •

March 26, 2009 at 02:20:41
FritzTheCat, 'if/then' or 'if/then/else'?
Ed in Texas.

Report •

March 26, 2009 at 03:09:55
No, the 'which' command in UNIX is used to find the first location of a file in the current PATH. For example, 'which perl' might return /usr/local/bin/perl.

Report •

March 26, 2009 at 08:09:33
closest I think you can get to which is the dir command

c:\>dir filename.ext /s

This will list the file sought and its path. You would have to determine which was the shortest path.

Report •

Related Solutions

March 26, 2009 at 12:01:55
Here's a site that's ported several unix utilities, including "which" to DOS:

I tried it and it seems to work...

Report •

March 26, 2009 at 13:25:27
Thanks kptech, that's exactly what I needed...lots of other goodies (grep, awk) on that site as well.

Report •

March 26, 2009 at 14:59:10
See also unix services 3.5. It has many ported tools.

"Best Practices", Event viewer, host file, perfmon, antivirus, anti-spyware, Live CD's, backups, are in my top 10

Report •

March 26, 2009 at 23:01:27
@echo off & setLocal EnableDelayedExpansion

if %1'==' goto :eof

for %%a in (%path%) do (
dir /b %%a | find /i "%1" > nul
if not errorlevel 1 echo %1 is in %%a && goto :eof

If at first you don't succeed, you're about average.


Report •

Ask Question