WSL

How to run .sh or Shell Script file in Windows 10

How to run .sh or Shell Script file in Windows 10

Shell Scripts or .SH files are like batch files of Windows which can be executed in Linux or Unix. It is possible to run .sh or Shell Script file in Windows 10 using Windows Subsystem for Linux. In this post, we will show you how to run a Shell Script file in Windows 10.

How to run .sh or Shell Script file in Windows 10

Bash is a Unix shell and command language which can run Shell Script files. You do not need to install Ubuntu or any other Linux Distros unless your scripts need the support of the real Linux kernel. We will share both the methods.

  1. Execute Shell Script file using WSL
  2. Execute Shell Script using Ubuntu on Windows 10

1] Execute Shell Script file using WSL

Install WSL or Windows Subsystem for Linux

Go to Settings > Update & Security > For Developers. Check the Developer Mode radio button. And search for “Windows Features”, choose “Turn Windows features on or off”.

Scroll to find WSL, check the box, and then install it. Once done, one has to reboot to finish installing the requested changes. Press Restart now.  BASH will be available in the Command Prompt and PowerShell.

Execute Shell Script Files

  1. Open Command Prompt and navigate to the folder where the script file is available.
  2. Type Bash script-filename.sh and hit the enter key.
  3. It will execute the script, and depending on the file, you should see an output.

On a Linux platform, you usually use SH, but here you need to use BASH. That said, BASH in Windows has its limitations, so if you want to execute in a Linux environment, you need to install Ubuntu or anything similar.

2] Execute Shell Script using Ubuntu on Windows 10

Make sure you have Ubuntu or any other Linux distros installed.  Ubuntu will mount or make all your Windows directories available under /mnt. So the C drive is available at /mnt/C.  So if the desktop will be available at /mnt/c/users//desktop.

Now follow these steps

  1. Type Bash in run prompt, and it will launch the distro prompt.
  2. Navigate to the folder using “cd” command to the folder where the scripts are available.
  3. Type “sh script.sh” and hit enter.

It will execute the script, and if they have a dependency on any of core Linux features.

Since Linux is now available in Windows, you need not use any third party applications like Cygwin. WSL should be enough for most of the scenarios to help you run a shell script in Windows 10.

Cum se folosește GameConqueror Cheat Engine în Linux
Articolul acoperă un ghid despre utilizarea sistemului de înșelăciune GameConqueror în Linux. Mulți utilizatori care joacă jocuri pe Windows folosesc ...
Cele mai bune emulatoare pentru console de jocuri pentru Linux
Acest articol va enumera programele populare de emulare a consolei de jocuri disponibile pentru Linux. Emularea este un strat de compatibilitate softw...
Best Linux Distros for Gaming in 2021
The Linux operating system has come a long way from its original, simple, server-based look. This OS has immensely improved in recent years and has no...