Hello World Program

Hello World Program - Shell Scripting

Hello World Program - Shell Scripting - 5.0 out of 5 based on 1 vote
User Rating:  / 1
PoorBest 

Code: 

Open a editor and write the below mentioned code

#!/bin/bash

echo "Hello World!!!"

To Execute:

sh helloworld.sh

or

bash helloworld.sh

or

chmod 755 ./helloworld.sh

./helloworld.sh

Explanation:

#! is called shebang code

shebang is used to represent the way to execute the script. This is a Unix concept. Its applicable for all scripting language on Unix flavoured operating systems. shebang code is a good practice to write in a scripting language.

shebang code has to be the files first character. if you write shebang code in second line then it will be treated as comment.

shebang code is not mandatory in a script file. Without shebang also a script can execute. Shebang is required when you execute using ./filename( ./helloworld.sh).

 

echo is a command which will print all the contents to the terminal or output.

 

You are here: Home Tutorials Shell Scripting Hello World Program