How to Run Shell Script in Windows?

How to Run Shell Script in Windows?


For those who don’t know what shell scripts are, they are batch files in Windows that are executed in Linux and Unix. In order to run the Shell Script on Windows 10, the user can use the Windows Subsystem, because it will become easier this way. Unix shell is like an interpreter, and there are many dialects of shell scripts.

Run Shell Script in Windows Overview

Run Shell Script in Windows

 

Run Shell Script in Windows Run Shell Script in Windows

These are often considered to be scripting languages and have three main purposes; manipulating files, executing programs, and printing text.

Such files have ASCII text, and in order to create a Shell Script, the user can benefit from a text editor. It is a program similar to a word processor, and there are many such editors available for Linux. Some Windows 10 Power Tie Run of the best text editors include Emacs, nano, edit and write. With the help of these editors, the user can write their own Shell Scripts.

Bash can be described as a command language, which is responsible for running Shell Script files; it can be defined as Unix Shell as well. the user doesn’t have to install Ubuntu unless the scripts need Linux kernel support. There are two methods of running the Shell Script on Windows 10.

1) Executing the Shell files with WSL

Search for Windows Subsystem for Linux, and install it. Go to Settings of the PC, click on Update and Security, and then on For Developers. You need to check the Developer Mode radio button here and then look for Windows Features. Now, choose the option which says ‘Turn Windows Features on or off’.

There, you will find WSL that has been downloaded before; check its box, and then install it. When the installation process id one, then reboot the system by pressing restart. BASH is now available in Command Prompt, as well as in the PowerShell.

Run Shell Script in Windows

Now, the Shell Script files have to be executed. First, open the Command Prompt, and then navigate to where the script file is saved. Type the file name of Bash, and then press enter. The script will not execute, and as per the file, the user will see the output.

Those who use the Linux platform, they use SH, but on Windows, BASH is used. However, BASH has its limitations, but it still works for Windows, while Ubuntu works for a Linux environment.

2) Ubuntu

For this method, the user needs to download Ubuntu first. Ubuntu has the ability to show all directories visible to the user under /mnt. The C drive of the user is available at /mnt/C, and for the desktop, the user will have to access /mnt/c/users/<your username>/desktop.

Rum prompt and then type BASH into it. As the distro prompt launches, navigate to the folder that says ‘cd’, and then move to the folder where the scripts are available. Type ‘sh script.sh’, and then press enter.

Linux is usually available on Windows, so the user doesn’t have to use 3rd party software or applications. WSL, which is described in the first method, would be enough to run Shell Script in Windows 10 or other versions.


Leave a Comment