shell scripting in linux

What is Linux ?
Linux is an open-source operating system modelled on UNIX.

What is Shell Script ?

A shell script is a computer program designed to be run by the Unix shell, a command line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Different types of shell in linux ?
Bourne shell (sh)
C shell (csh)
TC shell (tcsh)
Korn shell (ksh)
Bourne Again SHell (bash)

I like Bourne shell(sh), you will find many of my scripts in sh.

Bourne shell (sh):
This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems.The Bourne shell does provide an easy to use language with which you can write shell scripts.

Purpose of Shell script ?
Many a times we do repetitive work, for example.
1. Taking Database dumps
2. Generating Reports
3. Configuration Backup’s etc..

The above tasks can be automated with the help of scripting.

Writing your first script and getting it work!!


To successfully write a shell script, you have to do three things:

1. Write a script
2. Give the shell permission to execute it
3. Put it somewhere the shell can find it

Writing Script :-
A shell script is a file that contains ASCII text. To create a shell script, we can use a text editor.
A text editor is a program, like a word processor, that reads and writes ASCII text files.
There are many text editors available for your Linux system, both for the command line environment and the GUI environment.
Here is a list of some common ones:
gedit etc.

Writing your first script
#My First Script to print text
#Author : xyz
#Developed Date : dd/mm/yyyy
echo “Hello, This is my first script”
save and exit.

Give executable permissions,
chmod 755

we can run the script in two ways,
1. sh
2. ./

After running script, you should see “Hello, This is my first script” . you have just wrote a simple shell script and it worked!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>