Write the first bash script on a Windows machine

Writing a bash script is super easy, and in this tutorial, we will learn how to write our first bash script on a Windows computer.

What is a bash script?

A bash script contains the sequence of commands that a bash program executes. Using a bash script, you can carry out a sequence of operations. For instance, browsing to a certain directory, making a folder, making new files within that folder, and starting a process are all examples of command-line operations.

Requirements for bash scripting

Download and install git from this link.
https://git-scm.com/downloads

Now you are ready to write the bash script on your Windows machine. Follow these steps.

1. Open the gitbash terminal on a Windows machine.

2. Go to any folder and write nano bash.sh command to create a new bash file.

3. This command will also pop up an editor window.

4. The bash script always starts with the #! /bin/bash command. You can write the bash command to get the bash file path.

5. In this first bash script, I would like to print my name.

6. Pressing ctrl+x and writing y will save the script.

8. To run the script, write bash bash.sh

,

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

Back To Top