Bash Scripting “Hello World”
- Read
- Discuss
Bash scripting is a powerful technique for automating tasks and customizing the behavior of various software tools on Unix-based systems. It allows users to write simple scripts to perform complex operations by combining commands and utilities already available on the system.
Bash scripts are interpreted by the bash shell, the default command-line interface on most Linux distributions. The bash syntax is straightforward, making it easy for users to learn and start writing their scripts.
Let’s write our first Script!
- Open your terminal or shell.
- Create a new file using a text editor of your choice. For example, you can use the nano editor to create a file called “hello.sh”:
nano hello.sh
- Type the following code into the file:
#!/bin/bash
echo "Hello World"
- Save the file and exit the editor.
- Make the file executable by running the following command in the terminal:
chmod +x hello.sh
- Finally, run the script by typing:
./hello.sh
You should see the message “Hello World” printed in the terminal as shown in the screenshot below.
And that’s it! This is a simple example of how to write and run a Bash script. With this basic understanding, you can start exploring the capabilities of Bash scripts and automate various tasks on your system.
2 responses to “Bash Scripting “Hello World””
hello
hi
Leave a Reply
You must be logged in to post a comment.