Sunday, March 13, 2011

Hello World script to demonstrate shell script creation and execution

In any programming language, first program will be classic "Hello World!" program. So our first script will be classic "Hello World!"

Prerequisite:
Any shell. Preferably bash
Any editor which is convenient to you.Preferably vi. But there is no need of editor to write simple shell script.

STEP 1: Creation of script file with name as hello.sh
volcano@volcano-laptop:~/shellscript$ cat > hello.sh

#!/bin/bash
#Script to demonstrate
echo "Hello World!"

STEP 2: Setting up execute permission to the script
volcano@volcano-laptop:~/shellscript$ chmod u+x hello.sh 

STEP 3: Execution of script in the command line
volcano@volcano-laptop:~/shellscript$ ./hello.sh 
Hello World!

No comments:

Post a Comment