The 'which' utility, when run with a parameter naming an executable, will tell you the first executable with that name it finds in your path, if found at all. This gives a good idea which version of the executable will be run. (Forgive me if this description is incomplete, but it conveys the general idea)
I'm looking for either a port of the 'which' utility, a Powershell command, or some other utility I'm not aware of that does the same thing.
I have looked at the following SO question (and will try the for loop logic in the selected answer). I'd prefer to have a single command that implements this functionality and want to see if that exists. If something like that doesn't exist, that logic would be fairly easily put into a script:
unix "which java" equivalent command on windows?
The "winwhich" utility on CodeProject exists. It hasn't been updated in 6 years or so and, when built on my Win 7 machine with VS 2010, crashed upon running. I plan to do my due diligence to find out why it crashed, but don't have time until tonight.
Has anybody used another utility or command on Windows to emulate this functionality?
PowerShell is superficially similar to Unix shells. PowerShell has aliases for many of the commands you are used to in Unix, like ls, rm, cp, mv, etc. However, the way that the cmdlets behind the aliases work is quite different.
There is no Unix-style job-control support in PowerShell on Linux or macOS. The fg and bg commands are not available. You can use PowerShell jobs that do work across all platforms. Putting & at the end of a pipeline causes the pipeline to be run as a PowerShell job.
What is cat equivalent command in windows? The type command is a Windows cat equivalent that works on command-line prompt and a Windows PowerShell.
You can use Get-Command <command>
, or shorten it to gcm
.
where
does the same on recent versions of Windows. If you're after a PowerShell command, Novakov's answer is correct.
On Windows from Command Prompt (cmd)
cmd> where <command>
In Powershell (PS)
ps> get-command <command>
ps> where.exe <command>
You can also add alias to the 'which' command in PS
ps> New-Alias which get-command
and now you can use 'which' command like usual
ps> which <command>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With