In cygwin, I could just do ./script.sh args, but this opens the script file in notepad in PowerShell.
What do I need to do have it execute?
BASH will be available in the Command Prompt and PowerShell. Open Command Prompt and navigate to the folder where the script file is available. Type Bash script-filename.sh and hit the enter key. It will execute the script, and depending on the file, you should see an output.
Use bash: Right-click Start menu > select Windows PowerShell (Admin) > type "bash" > press Enter.
Press Windows key + X then click Command prompt, at the command prompt, type: bash then hit Enter. If you want to be able to access the local file system, press Windows key + X, Command Prompt (Admin) then type bash at the prompt.
A . SH file is very similar to the batch file of the Windows operating system and can be run in the Linux-based operating system. It is also possible to run . SH file in Windows 10 using Windows Subsystem for Linux.
There is now a "native" solution on Windows 10, after enabling Bash on Windows, you can enter Bash shell by typing bash
:
You can run Bash script like bash ./script.sh
, 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.
You should put the script as argument for a *NIX shell you run, equivalent to the *NIXish
sh myscriptfile
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