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

What's hot (20)

Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Vi editor in linux
Vi editor in linuxVi editor in linux
Vi editor in linux
 
Shell programming
Shell programmingShell programming
Shell programming
 
Introduction to SSH
Introduction to SSHIntroduction to SSH
Introduction to SSH
 
User management
User managementUser management
User management
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Shell Scripting Tutorial | Edureka
Shell Scripting Tutorial | EdurekaShell Scripting Tutorial | Edureka
Shell Scripting Tutorial | Edureka
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
Grep - A powerful search utility
Grep - A powerful search utilityGrep - A powerful search utility
Grep - A powerful search utility
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Multithreading
MultithreadingMultithreading
Multithreading
 
SSH
SSHSSH
SSH
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 

Similar to Shell Scripting in Linux

Bash shell programming in linux
Bash shell programming in linuxBash shell programming in linux
Bash shell programming in linuxNorberto Angulo
 
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 introAcácio Oliveira
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Scriptstudent
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptxHarsha Patel
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptxHarsha Patel
 
basic shell scripting syntex
basic shell scripting syntexbasic shell scripting syntex
basic shell scripting syntexKsd Che
 
(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorial(Ebook) linux shell scripting tutorial
(Ebook) linux shell scripting tutorialjayaramprabhu
 
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 | EdurekaEdureka!
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell ScriptAmit Ghosh
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxNourhanTarek23
 
Linnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptxLinnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptxShanBhoharia
 
Bash shell
Bash shellBash shell
Bash shellxylas121
 

Similar to Shell Scripting in Linux (20)

Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
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
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Linnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptxLinnux & Shell scripts Commands.pptx
Linnux & Shell scripts Commands.pptx
 
Bash shell
Bash shellBash shell
Bash shell
 

Recently uploaded

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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.pdfsudhanshuwaghmare1
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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 WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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