Run shell scripts on Powershell (without WSL or WSL2)

Prerequisites:

I assume you have Powershell installed (you will not need the hassle of installing WSL or WSL2 for this)

The easiest solution is to install Git first, which by default (at the time of this post) installs bash and sh binaries.

The binaries can be found under “C:\Program Files\git\bin\”

Steps:

Add the path of these binaries to Windows Environment Variables:

  1. Search “Edit the system environment variables” on Windows search bar and open it.

  2. Click on “Environment Variables” button

  3. On the top pane, click on “Path” such that it is highlighted in blue.

  4. Click “Edit”

  5. Click “New”

  6. Copy-paste “C:\Program Files\git\bin\”

  7. Then click “OK” until the environment variables window application is closed (“OK” 3 times)

Restart Powershell

Now you can run shell scripts by prepending the shell script name with “sh” or “bash” like:

$sh sample_shellScript.sh

Previous
Previous

Sniff packets in WSL on Windows

Next
Next

Computing inverse of a singular matrix for your ML model in Numpy/PyTorch/TensorFlow