SlideShare a Scribd company logo
1 of 18
SYSTEM PROGRAMING
Software Engineering
Shell Programming…
Rahmatullah Danish
danishkakar00@gmail.com
RAHMATULLAH DANISH
1
 Introduction to Shell & shell
scripting
 Lecture 11
INTRODUCTION TO
SHELL & SHELL SCRIPTING
• If you are using any major operating system you are indirectly interaction to shell.
• If you are running any Linux distribution, you are interacting to shell every time you
use terminal.
RAHMATULLAH DANISH
2
BEFORE
UNDERSTANDING SHELL
• Kernel
• Shell
• Terminal
RAHMATULLAH DANISH
3
WHAT IS KERNEL?
• The Kernel is a computer program that is the core of computer’s operating system.
• Which complete control over everything in the system.
• It manages..
• File management
• Process management
• I/O management
• Memory management
• Device management etc…
RAHMATULLAH DANISH
4
WHAT IS SHELL?
• A shell is a special user program which provide an interface to user to use operating
system services.
• Shell accept human readable commands from user and convert them into
something which kernel can understand.
• The shell gets started when the user logs in or start the terminal.
• A bash script is a series of commands written in a file. These are read and executed
by the bash program. The program executes line by line.
RAHMATULLAH DANISH
5
WHAT IS
SHELL
Hard
ware
Kernel
Utilities
Shell
bash
csh
ksh
ls
wget
cat
ps
nano
RAHMATULLAH DANISH
6
WHAT IS SHELL
Shell is broadly classified into two categories.
• Command line shell
• Graphical shell
RAHMATULLAH DANISH
7
COMMAND LINE SHELL
• Shell can be accessed by user using a command line interface.
• A special program called Terminal in Linux/macOS or Command Prompt in
Windows OS.
• It is very powerful, it allows user to store commands in a file and execute them
together.
• These files are usually called batch files in Windows and Shell Scripts in
Linux/macOS systems.
RAHMATULLAH DANISH
8
GRAPHICAL SHELLS
• Graphical shells provide means for manipulating programs based on graphical user
interface (GUI).
• Window OS or Ubuntu OS can be considered as good example which provide GUI
to user for interacting with program.
RAHMATULLAH DANISH
9
AVAILABLE SHELL FOR
LINUX
BASH
CSH
KSH
RAHMATULLAH DANISH
10
AVAILABLE SHELL
• BASH (Bourne Again SHell) – It is most widely used shell in Linux systems. It is used
as default login shell in Linux systems and in macOS. It can also be installed on
Windows OS.
• CSH (C SHell) – The C shell’s syntax and usage are very similar to the C
programming language.
• KSH (Korn SHell) – The Korn Shell also was the base for the POSIX Shell standard
specifications etc.
RAHMATULLAH DANISH
11
SHELL SCRIPTING
• Usually shells are interactive that mean, they accept command as input from users and
execute them.
• However some time we want to execute a bunch of commands routinely, so we have type in
all commands each time in terminal.
• As shell can also take commands as input from file we can write these commands in a file
and can execute them in shell to avoid this repetitive work.
• These files are called Shell Scripts or Shell Programs.
RAHMATULLAH DANISH
12
SHELL SCRIPTING
• Each shell script is saved with .sh file extension e.g. test.sh
A shell script comprises following elements –
• Shell Keywords – if, else, break etc.
• Shell commands – cd, ls, echo, pwd, touch etc.
• Functions
• Control flow – if..then..else, case and shell loops etc.
RAHMATULLAH DANISH
13
WHY WE USE SHELL SCRIPTS
There are many reasons to write shell scripts:
• To avoid repetitive work and automation
• System admins use shell scripting for routine backups
• System monitoring
• Adding new functionality to the shell etc.
RAHMATULLAH DANISH
14
ADVANTAGES OF SHELL SCRIPTS
• The command and syntax are exactly the same as those directly entered in
command line, so programmer do not need to switch to entirely different syntax
• Writing shell scripts are much quicker
• Quick start
• Interactive debugging etc.
RAHMATULLAH DANISH
15
DISADVANTAGES OF SHELL SCRIPTS
• Prone to costly errors, a single mistake can change the command which might be
harmful
• Slow execution speed
• Design flaws within the language syntax or implementation
• Not well suited for large and complex task
• Provide minimal data structure unlike other scripting languages. etc
RAHMATULLAH DANISH
16
SYNTAX OF BASH SCRIPT
• Scripts start with a bash bang.
• Create a file test.sh
• executes rights
• Run the script
#! /bin/bash
chmod u+x test.sh
touch test.sh
./test.sh
RAHMATULLAH DANISH
17
DEFINE VARIABLES
#!/bin/bash
# A simple variable example
greeting=Hello
name=Studens
echo $greeting $name
RAHMATULLAH DANISH
18

More Related Content

Similar to Shell programing|Shel Scripting

Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Chander Pandey
 
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...Flexera
 
Shell scrpting(payal harne)
Shell scrpting(payal harne)Shell scrpting(payal harne)
Shell scrpting(payal harne)PayalHarne
 
Deepa ppt about lamp technology
Deepa ppt about lamp technologyDeepa ppt about lamp technology
Deepa ppt about lamp technologyDeepa
 
lamp technology
lamp technologylamp technology
lamp technologyDeepa
 
Linux week 2
Linux week 2Linux week 2
Linux week 2Vinoth Sn
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introductionWingston
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUXSHUBHA CHATURVEDI
 
chapter-1-introduction-to-linux.ppt
chapter-1-introduction-to-linux.pptchapter-1-introduction-to-linux.ppt
chapter-1-introduction-to-linux.pptshivushivu20
 

Similar to Shell programing|Shel Scripting (20)

Presentation on rhce
Presentation on rhcePresentation on rhce
Presentation on rhce
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...
Shell vs. Java: Overcoming the Challenges of Shell Scripting for UNIX Install...
 
Shell scrpting(payal harne)
Shell scrpting(payal harne)Shell scrpting(payal harne)
Shell scrpting(payal harne)
 
Deepa ppt about lamp technology
Deepa ppt about lamp technologyDeepa ppt about lamp technology
Deepa ppt about lamp technology
 
lamp technology
lamp technologylamp technology
lamp technology
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Linux forensics
Linux forensicsLinux forensics
Linux forensics
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Line
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Line
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Linux unix-commands
Linux unix-commandsLinux unix-commands
Linux unix-commands
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
 
Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
Shell Basics
Shell BasicsShell Basics
Shell Basics
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Linux
LinuxLinux
Linux
 
chapter-1-introduction-to-linux.ppt
chapter-1-introduction-to-linux.pptchapter-1-introduction-to-linux.ppt
chapter-1-introduction-to-linux.ppt
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 

Shell programing|Shel Scripting

  • 1. SYSTEM PROGRAMING Software Engineering Shell Programming… Rahmatullah Danish danishkakar00@gmail.com RAHMATULLAH DANISH 1  Introduction to Shell & shell scripting  Lecture 11
  • 2. INTRODUCTION TO SHELL & SHELL SCRIPTING • If you are using any major operating system you are indirectly interaction to shell. • If you are running any Linux distribution, you are interacting to shell every time you use terminal. RAHMATULLAH DANISH 2
  • 3. BEFORE UNDERSTANDING SHELL • Kernel • Shell • Terminal RAHMATULLAH DANISH 3
  • 4. WHAT IS KERNEL? • The Kernel is a computer program that is the core of computer’s operating system. • Which complete control over everything in the system. • It manages.. • File management • Process management • I/O management • Memory management • Device management etc… RAHMATULLAH DANISH 4
  • 5. WHAT IS SHELL? • A shell is a special user program which provide an interface to user to use operating system services. • Shell accept human readable commands from user and convert them into something which kernel can understand. • The shell gets started when the user logs in or start the terminal. • A bash script is a series of commands written in a file. These are read and executed by the bash program. The program executes line by line. RAHMATULLAH DANISH 5
  • 7. WHAT IS SHELL Shell is broadly classified into two categories. • Command line shell • Graphical shell RAHMATULLAH DANISH 7
  • 8. COMMAND LINE SHELL • Shell can be accessed by user using a command line interface. • A special program called Terminal in Linux/macOS or Command Prompt in Windows OS. • It is very powerful, it allows user to store commands in a file and execute them together. • These files are usually called batch files in Windows and Shell Scripts in Linux/macOS systems. RAHMATULLAH DANISH 8
  • 9. GRAPHICAL SHELLS • Graphical shells provide means for manipulating programs based on graphical user interface (GUI). • Window OS or Ubuntu OS can be considered as good example which provide GUI to user for interacting with program. RAHMATULLAH DANISH 9
  • 11. AVAILABLE SHELL • BASH (Bourne Again SHell) – It is most widely used shell in Linux systems. It is used as default login shell in Linux systems and in macOS. It can also be installed on Windows OS. • CSH (C SHell) – The C shell’s syntax and usage are very similar to the C programming language. • KSH (Korn SHell) – The Korn Shell also was the base for the POSIX Shell standard specifications etc. RAHMATULLAH DANISH 11
  • 12. SHELL SCRIPTING • Usually shells are interactive that mean, they accept command as input from users and execute them. • However some time we want to execute a bunch of commands routinely, so we have type in all commands each time in terminal. • As shell can also take commands as input from file we can write these commands in a file and can execute them in shell to avoid this repetitive work. • These files are called Shell Scripts or Shell Programs. RAHMATULLAH DANISH 12
  • 13. SHELL SCRIPTING • Each shell script is saved with .sh file extension e.g. test.sh A shell script comprises following elements – • Shell Keywords – if, else, break etc. • Shell commands – cd, ls, echo, pwd, touch etc. • Functions • Control flow – if..then..else, case and shell loops etc. RAHMATULLAH DANISH 13
  • 14. WHY WE USE SHELL SCRIPTS There are many reasons to write shell scripts: • To avoid repetitive work and automation • System admins use shell scripting for routine backups • System monitoring • Adding new functionality to the shell etc. RAHMATULLAH DANISH 14
  • 15. ADVANTAGES OF SHELL SCRIPTS • The command and syntax are exactly the same as those directly entered in command line, so programmer do not need to switch to entirely different syntax • Writing shell scripts are much quicker • Quick start • Interactive debugging etc. RAHMATULLAH DANISH 15
  • 16. DISADVANTAGES OF SHELL SCRIPTS • Prone to costly errors, a single mistake can change the command which might be harmful • Slow execution speed • Design flaws within the language syntax or implementation • Not well suited for large and complex task • Provide minimal data structure unlike other scripting languages. etc RAHMATULLAH DANISH 16
  • 17. SYNTAX OF BASH SCRIPT • Scripts start with a bash bang. • Create a file test.sh • executes rights • Run the script #! /bin/bash chmod u+x test.sh touch test.sh ./test.sh RAHMATULLAH DANISH 17
  • 18. DEFINE VARIABLES #!/bin/bash # A simple variable example greeting=Hello name=Studens echo $greeting $name RAHMATULLAH DANISH 18