0% found this document useful (0 votes)
4 views

OS-UNIT-5

Uploaded by

prajapati126697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

OS-UNIT-5

Uploaded by

prajapati126697
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Shell Scripting: Usually, shells are interactive, which means they accept commands as input

from users and execute them. However, sometimes we want to execute a bunch of
commands routinely, so we have to type in all commands each time in the terminal.
As a 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. Shell scripts are similar to the batch file in MS-
DOS. Each shell script is saved with `.sh` file extension e.g., myscript.sh.
A shell script has syntax just like any other programming language. If you have any
prior experience with any programming language like Python, C/C++ etc. It would be very
easy to get started with it.
A shell script comprises the 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.

Need of 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.

Some Advantages of shell scripts


• The command and syntax are exactly the same as those directly entered in the
command line, so programmers do not need to switch to entirely different syntax
• Writing shell scripts are much quicker
• Quick start
• Interactive debugging etc.

Some Disadvantages of shell scripts


• Prone to costly errors, a single mistake can change the command which might be
harmful.
• 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.

You might also like