Search This Blog

Wednesday, April 3, 2013

Powershell as Bash substitute on Windows

In Linux we have Bash shell that can be used to interact with the system or help to execute routine commands. There are couple of other alternatives in Windows. The cmd.exe is one of the interpreters that comes with every Windows since years.

A new one I'm learning is powershell.exe. The good part about powershell is that it provides many commands like in Linux that have the same name buy maybe a slightly different syntax  For a nice comparison list between the standard bash and powershell commands please take a look at BASH and PowerShell Quick Reference.


What is the Linux Path variable in powershell.


The variable is called $env:path.
PS C:\Users\radoslaw> echo $env:path
%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\AMD APP\bi
n\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;
 Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Git\cm
d;c:\Python27;c:\HP\DriveKey;C:\Program Files (x86)\PuTTY;C:\Ruby193\bin

You can modify it when navigating to:
Start - Computer - Properties - Advance system settings - Advanced-Environment Variables -System variables - Path

How to use 'curl' from powershell.


You can install cygwin on Windows. Add to the system PATH the cygwin bin directory. Alternatively you can use this command below to download a file.

PS C:\Users\radoslaw\tmp> (New-Object System.Net.WebClient).DownloadFile("", "tmp\")
PS C:\Users\radoslaw\tmp> ls

    Directory: C:\Users\radoslaw\tmp

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---          4/3/2013   9:12 PM      17319
-a---          4/3/2013   8:20 PM      85929


No comments:

Post a Comment