A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.
Types of shell scripts : Basically we have three types of the shell scripts [Most Prominent one’s ,widely used in industry].
1. Bourne Shell :
The Bourne shell, or sh, was the default Unix shell of Unix Version 7, and replaced the Thompson shell, whose executable file had the same name, sh. It was developed by Stephen Bourne, of AT&T Bell Laboratories, and was released in 1977 in the Version 7 Unix release distributed to colleges and universities. It remains a popular default shell for Unix accounts. The binary program of the Bourne shell or a compatible program is located at
/bin/sh on most Unix systems, and is still the default shell for the root superuser on many current Unix implementations.
Features of the Bourne shell include:
- Scripts can be invoked as commands by using their filename
- May be used interactively or non-interactively
- Allow both synchronous and asynchronous execution of commands
- supports input and output redirection and pipelines
- provides a set of built-in commands
- provides flow control constructs, quotation facilities, and functions.
- typeless variables
- provides local and global variable scope
- scripts do not require compilation before execution
- does not have a goto facility, so code restructuring may be necessary
- Command substitution using back quotes:
- Here documents using
<<to embed a block of input text within a script.
for ~ do ~ done" loops, in particular the use of
$*to loop over arguments.
case ~ in ~ esac" selection mechanism, primarily intended to assist argument parsing.
shprovided support for environment variables using keyword parameters and exportable variables.
- It contains strong provisions for controlling input and output and in its expression matching facilities.
2. C Shell :
The C shell is a command processor that's typically run in a text window, allowing the user to type commands which cause actions. The C shell can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. What differentiated the C shell, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable.
Features of C Shell :
Some of the features of the C shell are listed here:
- Customizable environment.
- Abbreviate commands. (Aliases.)
- History. (Remembers commands typed before.)
- Job control. (Run programs in the background or foreground.)
- Shell scripting. (One can write programs using the shell.)
- Keyboard shortcuts.
3. Korn Shell :
The Korn shell's major new features include:
Integrated programming features : the functionality of several external UNIX commands, including test , expr , getopt , and echo , has been integrated into the shell itself, enabling common programming tasks to be done more cleanly and without creating extra processes.
New options and variables that give you more ways to customize your environment.
Increased speed of shell code execution.