welcome to the video tutorial on shell
scripting operating systems are made of
many components but there are two prime
components are kernel and shell the
kernel is at the nucleus of a computer
it makes the communication between the
software and the hardware possible while
the kernel is the innermost part of an
operating system a shell is the
outermost one a shell in a Linux
operating system takes input from you in
form of commands processes them and then
gives an output it is the interface
through which a user works on the
program's commands and scripts a shell
is accessed by terminal which runs it
when you run the terminal the shell
issues a command prompt which is usually
the dollar sign wherein you can type
your input which is then executed when
you hit the enter key so if we type in
the PWD command and hit the enter key
the output or the result is thereafter
displayed on the terminal the shell
wraps around the delegate interior of an
operating system protecting it from
accidental damage hence the name
shell there are two main shells and
Neelix the first one is the bourne shell
the prompt for this shell is a dollar
sign and its derivatives are the POSIX
shell known as as H the conch shell also
known as as H and the bourne-again shell
also known as bash which is the most
popular of them all second one is the C
shell
the prompt for this shell is a
percentage sign and it's subcategories
are sea shell also known as CS h tops
sea shell also known as TCS H will
discuss bash shell base shell scripting
in this tutorial so what is shell
scripting and why do I need it writing a
series of command for the shell to
execute is called shell scripting it can
combine lengthy and repetitive sequences
of commands into a single and simple
script which can be stored and execute
it anytime this reduces the effort
required by the end-user let us
understand the steps in creating a shell
script first create a file using a VI
editor or any other text editor second
nameless curve filed with an extension
dot as H side the script with the hash
sign followed by shriek followed by the
been SH path write some code save the
script file as file name dot as H for
executing the script type bash followed
by file name dot as H here the hash sign
followed by shriek is an operator Khalsa
Bank which directs the scripts to the
interpretation location let's create a
small script using the VI editor will
start with typing VI followed by the
file name
do not forget to enter the SH extension
by pressing the i key on the keyboard
will enter the insert mode of the VI
editor let's start with the script you
need to start your script with shebang
sign followed by the bin SH path every
time you create a shell script let's
type in the command and quickly go ahead
and save this file now in order to run
the script we need to type in bash
followed by the script name again do not
forget to type in the SH extension upon
hitting the enter key we will see that
the command LS is executed commenting is
important in any program in shell the
syntax to add a comment as the hash sign
followed by the comment that is
understand this with an example
so let us create another sample script
now you'd again start with the bank sign
followed by the bin as age path let us
execute the command PWD now here we
would like to add a comment which will
tell us that the PWD command stands for
present working directory let us quickly
go ahead and save the script now upon
running script 1.8 we will find that the
PWD command was executed but the comment
present working directory was ignored
moving on to what I shall variables has
discussed earlier variable stored data
in form of characters and numbers
similarly shell variables are used to
store information and they can be read
by the shell only for example this piece
of script creates a shell variable and
then prints end this is a small script
which will create and it will use
variables so let us start with creating
the script
we start the script as usual with the
shebang followed by the bend as h path
now let us start with writing the script
as we have completed writing the script
let us go ahead and save it now let us
go ahead and run the script file for
this we need to type in bash followed by
the script name which is easy script dot
s H in our case once we hit the enter
key the script starts executing and it
asks us what is your name we will type
in the name guru nine nine upon hitting
the enter again the script now tells us
how do you do and it echoes our name let
us put in good as you can see here the
script repeats the remark that we have
entered this is how we can create script
based on bash shell now this is a simple
script you can develop advanced scripts
which contain conditional statements
loops and functions shell scripting will
make your life easy and Linux
administration a breeze let us quickly
recap what we learnt in this tutorial
kernel is the nucleus of the operating
systems and it communicates between
hardware and software shell is a program
which interprets user commands through
CLI like terminal the bourne shell and
the c shell are the most used shells in
linux shell scripting is writing a
series of commands for the shell to
execute shell variables store the value
of a strength or a number for the shell
to read shell scripting can help you
create complex programs containing
conditional statements loops and
functions thank you for watching this
tutorial out see you in the next one