Run bash script from Windows PowerShell


In cygwin, I could just do ./ args, but this opens the script file in notepad in PowerShell.

What do I need to do have it execute?

7/8/2009 3:22:30 PM

Accepted Answer

You should put the script as argument for a *NIX shell you run, equivalent to the *NIXish

sh myscriptfile
7/8/2009 4:16:11 PM

There is now a "native" solution on Windows 10, after enabling Bash on Windows, you can enter Bash shell by typing bash: Bash on Windows

You can run Bash script like bash ./, but keep in mind that C drive is located at /mnt/c, and external hard drives are not mountable. So you might need to change your script a bit so it is compatible to Windows.

Also, even as root, you can still get permission denied when moving files around in /mnt, but you have your full root power in the / file system.

Also make sure your shell script is formatted with Unix style, or there can be errors. Example script

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow