2

A friend told me that Windows PowerShell doesn't have these Unix-style commands. Well, I tried and saw that I can in fact run these.

Now I'm wondering why is that. Could it be because I have installed NodeJs on this Windows machine?

If they are not by default usable in Windows PowerShell, is there a way to find out what exactly has brought them into use in this Windows installation?

Running Windows 8.1.


For those that are interested, based on the chosen answer, I found out that installing Git on this machine has brought those commands to use:

PS C:\Users\myusername> where.exe grep
C:\Users\myusername\AppData\Local\Programs\Git\usr\bin\grep.exe

PS C:\Users\myusername> where.exe less
C:\Users\myusername\AppData\Local\Programs\Git\usr\bin\less.exe
phuclv
  • 37,963
  • 15
  • 156
  • 475
Steve Waters
  • 3,348
  • 9
  • 54
  • 94

2 Answers2

3

You can try this

where.exe find
where.exe less
where.exe grep

They'll return the path to the exe file if those tools exist on your PC. You can always run find because there's find.exe, although it's not Unix find but a tool for searching text. less and grep won't be available by default but if you have Cygwin, MSYS or Gnu32 installed then they'll be ready in path. Git on Windows runs on MSYS so unsurprisingly you can run less, grep or other Unix tools

Note that you need to use where.exe command instead of only where command like on cmd.exe because where on powershell has a different meaning

phuclv
  • 37,963
  • 15
  • 156
  • 475
2

If you wonder why you can see them, you can run the Get-Command command, which will tell you where the files are being called from (also a great tool to find the underlying VBS scripts which get called when you run commands from time to time)

For instance, the LS command works in PowerShell, but it isn't actually the same binary used in Bash.

_>Get-Command ls

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           ls -> Get-ChildItem

We can see here that in this case, running LS is actually a PowerShell alias which calls the Cmdlet (that is to say, the native PowerShell command) of Get-ChildItem.

If you run this on the other commands you can determine why you see them. Maybe you install cygwin at some point, or installed Python / Ruby (some installers package Bash binaries).

FoxDeploy
  • 12,569
  • 2
  • 33
  • 48