SlideShare a Scribd company logo
1 of 12
Shell Scripting
           Linux shell programming




02/26/13
Introduction
• A shell is a program constructed of shell commands
  ( $shell,$path,Ls,pwd,mkdir..)
• Shell is an environment for user interaction.But it is
  not a part of kernel.
• Shell is just like as BAT files in MS-DOS.
• By default,Bash shell is default shell for Linux.




         02/26/13
Features of Shells
• Shells are CASE SENSITIVE.
• Shells allows interaction with kernel.
• Shells allow one to create functions and pass
  arguments to them.
• Shells provide help for each and every command
  using man or help.
• Helps in automation of tasks and thus time saving




02/26/13
Types of shells
• Following types of shells are available in linux:
           Shell Name      Developer     Promp Description
                                         t

            Bash –         Brian Fox &     $    Bash is the replacement
            Bourne again   Chet Ramey           of sh shell.It provides
                                                many tools for editing
                                                and manipulating
                                                history.
           CSH - C shell Bill Joy          %    C shell has its syntax
                                                much same as that of C
                                                language.
            Some other types of shells available are KSH Korn
           shell,TCSH tenex/Tops C shell


02/26/13
Shell Scripting
• A script is defined as just a plain text file or ASCII
   file
    – with a set of linux / unix commands.
    – Flow of control
    – IO facilities
• A shell script can be created using any
 text editor like vim,emac,notepad++ etc.




 02/26/13
• Shell script allow use of variables.
• Shell scripts are interpreted directly and are not
  compiled as cc++ codes.
• Shells provide many features including loop
  constructs,arrays,variables,branches and functions.
• shells provide logic with other utilities like
  pipelining,redirection etc.
• Shells allow file and directory management features.




02/26/13
Example of Shell scripting




02/26/13
Structure of a script
• #!/bin/bash –it defines that in which shell will be used
  to run the script.
• # comments –comments can be made by using #
  symbol in a script.
• Chmod +x script.sh – to tell the linux that file is
  executable.
• ./script.sh to execute the script.
              To check current shell ,type following:
     echo $SHELL.



02/26/13
Advantages of shell scripting
• Shell script is much quicker
  than programming in any
  other languages.

• To automate the frequently
  performed tasks.

• Easy to use and understand.
  Non-geeks can also modify
  scripts.
02/26/13
Disadvantages of shell scripting
• Slow execution speed.

• Prone to costly errors.

• Compatability problems




02/26/13
References
 Shell Scripting for Unix/Linux: Shell scripting
  advantages and disadvantages
 Bash Shell Script Function Examples
 Linux Shell Scripting Tutorial - A Beginner's
  handbook
 LinuxHelp.net




02/26/13
02/26/13

More Related Content

What's hot

Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 

What's hot (20)

Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Shell programming
Shell programmingShell programming
Shell programming
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2) Course 102: Lecture 16: Process Management (Part 2)
Course 102: Lecture 16: Process Management (Part 2)
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux directory structure by jitu mistry
Linux directory structure by jitu mistryLinux directory structure by jitu mistry
Linux directory structure by jitu mistry
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 

Similar to Shell Scripting in Linux

Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linux
Norberto Angulo
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
student
 
basic shell scripting syntex
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntex
Ksd Che
 
(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial
jayaramprabhu
 
Linnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptxLinnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptx
ShanBhoharia
 

Similar to Shell Scripting in Linux (20)

Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
Shell Basics
Shell BasicsShell Basics
Shell Basics
 
Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linux
 
Licão 02 shell basics bash intro
Licão 02 shell basics bash introLicão 02 shell basics bash intro
Licão 02 shell basics bash intro
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
 
basic shell scripting syntex
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntex
 
UnixShells.ppt
UnixShells.pptUnixShells.ppt
UnixShells.ppt
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
21bUc8YeDzZpE
21bUc8YeDzZpE21bUc8YeDzZpE
21bUc8YeDzZpE
 
(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial
 
Licão 05 scripts exemple
Licão 05 scripts exempleLicão 05 scripts exemple
Licão 05 scripts exemple
 
Bash vs C Shell vs Korn Shell | Edureka
Bash vs C Shell vs Korn Shell | EdurekaBash vs C Shell vs Korn Shell | Edureka
Bash vs C Shell vs Korn Shell | Edureka
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell Script
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
 
Linnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptxLinnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptx
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Shell Scripting in Linux

  • 1. Shell Scripting Linux shell programming 02/26/13
  • 2. Introduction • A shell is a program constructed of shell commands ( $shell,$path,Ls,pwd,mkdir..) • Shell is an environment for user interaction.But it is not a part of kernel. • Shell is just like as BAT files in MS-DOS. • By default,Bash shell is default shell for Linux. 02/26/13
  • 3. Features of Shells • Shells are CASE SENSITIVE. • Shells allows interaction with kernel. • Shells allow one to create functions and pass arguments to them. • Shells provide help for each and every command using man or help. • Helps in automation of tasks and thus time saving 02/26/13
  • 4. Types of shells • Following types of shells are available in linux: Shell Name Developer Promp Description t Bash – Brian Fox & $ Bash is the replacement Bourne again Chet Ramey of sh shell.It provides many tools for editing and manipulating history. CSH - C shell Bill Joy % C shell has its syntax much same as that of C language. Some other types of shells available are KSH Korn shell,TCSH tenex/Tops C shell 02/26/13
  • 5. Shell Scripting • A script is defined as just a plain text file or ASCII file – with a set of linux / unix commands. – Flow of control – IO facilities • A shell script can be created using any text editor like vim,emac,notepad++ etc. 02/26/13
  • 6. • Shell script allow use of variables. • Shell scripts are interpreted directly and are not compiled as cc++ codes. • Shells provide many features including loop constructs,arrays,variables,branches and functions. • shells provide logic with other utilities like pipelining,redirection etc. • Shells allow file and directory management features. 02/26/13
  • 7. Example of Shell scripting 02/26/13
  • 8. Structure of a script • #!/bin/bash –it defines that in which shell will be used to run the script. • # comments –comments can be made by using # symbol in a script. • Chmod +x script.sh – to tell the linux that file is executable. • ./script.sh to execute the script. To check current shell ,type following: echo $SHELL. 02/26/13
  • 9. Advantages of shell scripting • Shell script is much quicker than programming in any other languages. • To automate the frequently performed tasks. • Easy to use and understand. Non-geeks can also modify scripts. 02/26/13
  • 10. Disadvantages of shell scripting • Slow execution speed. • Prone to costly errors. • Compatability problems 02/26/13
  • 11. References  Shell Scripting for Unix/Linux: Shell scripting advantages and disadvantages  Bash Shell Script Function Examples  Linux Shell Scripting Tutorial - A Beginner's handbook  LinuxHelp.net 02/26/13