Skype: bluewindlab
Write the first bash script on a Windows machine

Writing a bash script is super simple and easy. If you are struggling to write the first bash script, then this tutorial is for you. In this tutorial, I will explain the steps to write your 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.

A bash script example with the steps of including files and a for loop.

🚀 Why I need to learn bash script?

  1. You can automate your tasks by writing few lines of code.
  2. Creating and deleting files with the bash script is super fast.
  3. You can search texts and files quickly compare to the GUI search.

👉 Requirements for bash scripting

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

download git bash desktop application to Mac

Now you are ready to write the bash script on your Windows/Mac 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
Premium WordPress Themes and Plugins By xenioushk
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.