You are on page 1of 11

SHELL SCRIPTING

Mehakpreet Kaur
A00127469
Introduction to shell

◦ Shell is basically a program which is intermediate between user and kernel.


◦ Understand the language of user (human language) and convert into kernel understandable
language.
◦  It gathers input from user and executes programs based on that input. When a program
finishes executing, it displays that program's output.
◦ Shell provides an environment where we can run programs, commands and scripts.
◦ Kernel :- heart of operating system.
another intermediator
Categories of shell

Graphical user interface (GUI) Command line interface (CLI)

◦ Mouse is the main input device to regulate ◦ User have to type for every actions even from
most of the operations. small to small action like moving from one
◦ Shell in this interface understand the language place to another.
of visual representation. ◦ To interact with shell in CLI interface we have
◦ Example :- windows to type script for it which is explained further.
SHELL SCRIPTING

◦ Whatever we write in command line operator under some guidelines to run in the Linux that
are known as shell scripting.
◦ In other words, shell script is the list of commands which listed in order for execution with
commands.
◦ We made shell script to avoid repetitive works.
◦ Mainly these shell scripts are used to regular system backups, to monitor the system.
Shebang operator ( #! /bin /sh )

◦   A shebang is the character sequence consisting of the characters number sign and 


exclamation mark (#!) at the beginning of a script.

◦ Hash (#) and bang (!) collectively said shebang.

◦ It is essential to type # ! /bin /sh in the first line to start the script.
How to write shell script
◦ Shell scripts are written in text editors. (vi editor)
◦ First of all, we open shell scripts with its name, vi [filename].sh

◦ Secondly we will do scripting in vi editor.


◦ Don’t forget #! /bin /sh
How to write shell script
◦ Example of shell scripting

◦ Assigning permission for execution of shell script, chmod u+x [filename].sh or chmod 700
[filename].sh
How to write shell script
◦ At the we will run our program through bash [filename].sh

You might also like