Shell Scripting Lesson 3 - Write your First Shell Script

This is My third shell scripting tutorial. In this tutorial, I am going to teach you how to write your very first shell Script. Simply says that Hello World shell script !

For this tutorial, I am using vim editor as my text editing tool.

Open a terminal of your Linux distribution. Type following command to create shell file.

$ vim myfirst.sh
Type following code snippet in it.
#!/bin/bash
# My first script
echo "Hello World!"


Save the script !
Type following shell command to set execution permission to your  shell script.
$ chmod +x script_name 
Or
$ chmod 755 script_name
In our example, Type chmod +x myfirst.sh  and press enter.

Run your Script !

Type one of following shell command.

$ bash myfirst
Or
$ sh myfirst
Or
$ ./myfirst

That's it !

Hello Word Text  will prints in your terminal. !

0 comments:

Post a Comment

Ask anything about this Tutorial.