What basically is a bash script? A bash script is a user generated scripts which runs through a bash shell and contains set of commands to serve a specific purpose. So before you may create a complex bash script you must have basic concepts of bash scripting. Here is a small tutorial which describes how to create a "Hello World" bash script. Creating a "Hello World" bash script in Linux requires no previous knowledge of bash scripting. All you need is to create a small script file and a command to execute it.

Hello World
Follow These Steps To Create Your First Bash Script In Ubuntu
- Open Text Editor by navigating to Applications->Accessories->Text Editor
Now copy and paste the following code in your text editor - Go to File->Save As or simply use SHIFT+CTRL+S to save the script. In the Name box type helloworld.sh. Choose Desktop from the Save in folder drop down list.
- Click on the Save button.
- Now open Terminal by navigating to Applications->Accessories->Terminal
- Use the following command to know where your bash interpreter is located
- As we have saved the helloworld.sh on our desktop, so first navigate to desktop and then use the following command to make the file executable.
- Use the following command to see the output of the bash script we have created.
#!/bin/bash
# Lets declare a STRING variable
STRING="Hello World"
#Using echo command to print value of a variable on screen
echo $STRING
which bash
cd Desktop
chmod +x helloworld.sh
./helloworld.sh
Complete Terminal Log For Hello World Bash Script
jaxov@ubuntu:~$ which bash
/bin/bash
jaxov@ubuntu:~$ cd Desktop
jaxov@ubuntu:~/Desktop$ chmod +x helloworld.sh
jaxov@ubuntu:~/Desktop$ ./helloworld.sh
Hello World
jaxov@ubuntu:~/Desktop$
RSS Feed
Google Buzz
Facebook
Twitter















