Unix Shell Scripts

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: `command`.
• 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.
• sh provided 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 (csh or the improved version, tcsh, on most machines) is a Unix shell that was created by Bill Joy while a graduate student at University of California, Berkeley in the late 1970s.
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 (ksh) is a Unix shell which was developed by David Korn (AT&T Bell Laboratories) in the early 1980s and announced at Toronto USENIX on July 14 1983
ksh is backwards-compatible with the Bourne shell and includes many features of the C shell as well, such as a command history, which was inspired by the requests of Bell Labs users.

The Korn shell's major new features include:
• Command-line editing , allowing you to use vi or emacs -style editing commands on your command lines.
• 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.
• Control structures , especially the select construct, which enables easy menu generation.
• Debugging primitives that make it possible to write tools that help programmers debug their shell code.
• Regular expressions , well known to users of UNIX utilities like grep and awk , have been added to the standard set of filename wildcards and to the shell variable facility.
• Advanced I/O features , including the ability to do two-way communication with concurrent processes (coroutines ).
• New options and variables that give you more ways to customize your environment.
• Increased speed of shell code execution.
• Security features that help protect against "Trojan horses" and other types of break-in schemes.



Related Posts Plugin for WordPress, Blogger...