Here I’m going to show you how to write a simple Linux shell script to print “Hello World” in the Linux command line.
Step 1 : To go to the home folder, type “cd /home” and press ‘Enter’ key.
Step 2 : To open a new file, type “vi hello.sh” and press ‘Enter’ key.
Step 3 : Press ‘Insert’ key and write following code;
#clear for clear the screen
#echo for print Hello World
echo “Hello World”
Step 4 : Press ‘Esc’ key and type “:wq” and press ‘Enter’ key to save the file.
Step 5 : Now type “ls” to list the file and check the file was created.
Step 6 : Now type “chmod +x hello.sh” and press ‘Enter’ key to make it as executable file.
Step 7 : Check the files again by typing “ls”. the file will be show in green color.
Step 8 : To run the shell script, type “./hello.sh” and press ‘Enter’ key. This will print “Hello World” in your screen.
This is the simplest shell script that you can star get familiar with writing Linux shell scripts, and explore the advance shell scripts.