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.
🚀 Why I need to learn bash script?
- You can automate your tasks by writing few lines of code.
- Creating and deleting files with the bash script is super fast.
- 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
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
