Information about Shell Script
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. Usually, shell script refers to scripts written for a Unix shell, while
Many shell script interpreters double as command line interface, such as the various Unix shells, Windows PowerShell or the MS-DOS
cp *.txt / cp *.mp3 /
This example also demonstrates the use of wildcard characters, a simple way of matching multiple related files ("*" denotes any sequence of characters). Most shells implement basic pattern matching capabilities like this, which allow them to perform commands on groups of items with similar names and sometimes parse simple strings of text.
Although each shell scripting language is different, there are a number of additional features which are often provided. One is a mechanism for manipulating some form of variables, in other words, named values which can be inserted elsewhere in the script at specified locations. For example, this script copies all .txt and .mp3 files from the current directory to the directory named by the variable "fuzzy":
cp *.txt $fuzzy cp *.mp3 $fuzzy
By changing the value of the variable "fuzzy", the user can specify to where the files are copied. However, rewriting a script to change a variable's definition each time the script is run would be a nuisance, so scripting languages typically also support special variables which provide access to any arguments passed to the script on the command line. For example,
Another common feature of shell scripting languages is some way of dealing with return codes, which are numbers returned from executed programs to indicate whether they succeeded or failed. In the Bourne shell, for example, the notation
Many modern shells also supply various features usually found only in more sophisticated general-purpose programming languages, such as control-flow constructs (if, while, goto), mutable variables, comments, subroutines, and so on. With these sorts of features available, it is sometimes possible to write reasonably sophisticated applications as shell scripts, although of course the more demanding, complex or large-scale systems will usually require more powerful programming languages. Though the shells are powerful in their way, they have few structuring mechanisms, limited built-in commands, and are generally interpreted relatively slowly.
For tasks deemed too large or complex to be comfortably handled with ordinary shell scripts, but for which the advantages of a script are desirable and the development overhead of a full-blown, compiled programming language would be disadvantageous, many powerful scripting languages have been introduced. The specifics of what separates scripting languages from high-level programming languages is a frequent source of debate.
Scripting languages (commonly called script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard.
..... Click the link for more information.
The term wildcard character has the following meanings:
..... Click the link for more information.
COMMAND.COM (DOS) and cmd.exe (Windows) command line scripts are usually called batch files, but here properties of both are discussed.
Many shell script interpreters double as command line interface, such as the various Unix shells, Windows PowerShell or the MS-DOS
COMMAND.COM. Others, such as AppleScript, add scripting capability to computing environments without requiring a command line interface. Other examples of programming languages primarily intended for shell scripting include DCL and JCL.
Capabilities
In their most basic form, shell scripts allow several commands that would be entered "by hand" at a command line interface to be executed automatically and rapidly. For example, the following Bourne shell script copies all text files (*.txt) and MP3 files (*.mp3) in the working directory to the root directory:cp *.txt / cp *.mp3 /
This example also demonstrates the use of wildcard characters, a simple way of matching multiple related files ("*" denotes any sequence of characters). Most shells implement basic pattern matching capabilities like this, which allow them to perform commands on groups of items with similar names and sometimes parse simple strings of text.
Although each shell scripting language is different, there are a number of additional features which are often provided. One is a mechanism for manipulating some form of variables, in other words, named values which can be inserted elsewhere in the script at specified locations. For example, this script copies all .txt and .mp3 files from the current directory to the directory named by the variable "fuzzy":
cp *.txt $fuzzy cp *.mp3 $fuzzy
By changing the value of the variable "fuzzy", the user can specify to where the files are copied. However, rewriting a script to change a variable's definition each time the script is run would be a nuisance, so scripting languages typically also support special variables which provide access to any arguments passed to the script on the command line. For example,
$1 through $9 refer to the first nine arguments given to a Bourne shell script, as do %1 through %9 in DOS batch files. Also, a shell's internal variables are often integrated with the operating system's notion of per-process or per-session environment variables.
Another common feature of shell scripting languages is some way of dealing with return codes, which are numbers returned from executed programs to indicate whether they succeeded or failed. In the Bourne shell, for example, the notation
a && b means to first execute a, then execute b only if a succeeded. Batch files use if errorlevel for this purpose.
Many modern shells also supply various features usually found only in more sophisticated general-purpose programming languages, such as control-flow constructs (if, while, goto), mutable variables, comments, subroutines, and so on. With these sorts of features available, it is sometimes possible to write reasonably sophisticated applications as shell scripts, although of course the more demanding, complex or large-scale systems will usually require more powerful programming languages. Though the shells are powerful in their way, they have few structuring mechanisms, limited built-in commands, and are generally interpreted relatively slowly.
Other scripting languages
For tasks deemed too large or complex to be comfortably handled with ordinary shell scripts, but for which the advantages of a script are desirable and the development overhead of a full-blown, compiled programming language would be disadvantageous, many powerful scripting languages have been introduced. The specifics of what separates scripting languages from high-level programming languages is a frequent source of debate.
Advantages
Often, writing a shell script is much quicker than writing the equivalent code in other programming or scripting languages. As with other interpreted languages, shell scripts have no compilation step, so the script can be executed quickly while debugging.Disadvantages
One significant disadvantage of using shell scripts is that they can run slowly due to the need to create potentially many new sub-processes for each of the many commands executed. When a script's job can be accomplished by setting up a pipeline in which efficient filter commands perform most of the work, the slowdown is minimal. But if a shell script has to perform multiple individual actions on many individual data items, resulting in multiple forks for each command invoked to perform each action, the script might be orders of magnitude slower than a conventional compiled program (in which those same actions might require but single processor instructions).Quotes
It is easier to port a shell than a shell script. -- Larry Wall
See also
External links
- ''UNIX / Linux shell scripting tutorial by Steve Parker
- Wicked Cool Shell Scripts by Dave Taylor
- Shell Scripting Recipes: A Problem-Solution Approach by Chris F.A. Johnson
- What to watch out for when writing portable shell scripts by Peter Seebach
- Zazzybob.com Shell Script Repository by Kevin Waldron
- Scripting redirects here. For other uses, see script.
Scripting languages (commonly called script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard.
..... Click the link for more information.
In computing, a shell is a piece of software that provides an interface for users. Typically, the term refers to an operating system shell which provides access to the services of a kernel.
..... Click the link for more information.
..... Click the link for more information.
command line interpreter (also command line shell, command language interpreter) is a computer program that reads lines of text entered by a user and interprets them in the context of a given operating system or programming language.
..... Click the link for more information.
..... Click the link for more information.
An operating system (OS) is the software that manages the sharing of the resources of a computer. An operating system processes system data and user input, and responds by allocating and managing tasks and internal system resources as a service to users and programs of the
..... Click the link for more information.
..... Click the link for more information.
A domain-specific programming language (domain-specific language, DSL) is a programming language designed for, and intended to be useful for, a specific kind of task.
..... Click the link for more information.
..... Click the link for more information.
Unix shell, also called "the command line", provides the traditional user interface for the Unix operating system and for Unix-like systems. Users direct the operation of the computer by entering command input as text for a shell to execute.
..... Click the link for more information.
..... Click the link for more information.
COMMAND.COM is the filename of the default operating system shell (or command line interpreter) for DOS and 16/32bits versions of Windows (95/98/98 SE/Me). It also has an additional role, as the first program run after boot, hence being responsible for setting up the system by
..... Click the link for more information.
..... Click the link for more information.
DOS (from Disk Operating System) commonly refers to the family of closely related operating systems which dominated the IBM PC compatible market between 1981 and 1995 (or until about 2000, if Windows 9x systems are included): DR-DOS, FreeDOS, MS-DOS, Novell-DOS, OpenDOS, PC-DOS,
..... Click the link for more information.
..... Click the link for more information.
cmd.exe is the command line interpreter on OS/2, Windows CE and on Windows NT-based systems (including Windows 2000, XP, Vista, and Server 2003). It is the analog of
..... Click the link for more information.
COMMAND.COM in MS-DOS and Windows 9x systems, or of the shells used on Unix systems...... Click the link for more information.
Microsoft Windows
Screenshot of Windows Vista Ultimate, the latest version of Microsoft Windows.
Company/developer: Microsoft Corporation
OS family: MS-DOS/9x-based, Windows CE, Windows NT
Source model: Closed source
..... Click the link for more information.
Screenshot of Windows Vista Ultimate, the latest version of Microsoft Windows.
Company/developer: Microsoft Corporation
OS family: MS-DOS/9x-based, Windows CE, Windows NT
Source model: Closed source
..... Click the link for more information.
Microsoft Batch File
File extension:
Type of format: Scripting In MS-DOS, OS/2, and Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter.
..... Click the link for more information.
File extension:
.bat .cmd .btm Type of format: Scripting In MS-DOS, OS/2, and Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter.
..... Click the link for more information.
command line interface or CLI is a method of interacting with an operating system or software using a command line interpreter. This command line interpreter may be a text terminal, terminal emulator, or remote shell client such as PuTTY.
..... Click the link for more information.
..... Click the link for more information.
Windows PowerShell, previously Microsoft Shell or MSH (codenamed Monad) is an extensible command line interface (CLI) shell and scripting language product developed by Microsoft. The product is based on object-oriented programming and version 2.
..... Click the link for more information.
..... Click the link for more information.
MS-DOS (short for Microsoft Disk Operating System) is an operating system commercialized by Microsoft. It was the most commonly used member of the DOS family of operating systems and was the dominant operating system for the PC compatible
..... Click the link for more information.
..... Click the link for more information.
AppleScript
Developer: Apple Inc.
Latest release: 1.10.7/ 2006-06-30
OS: Mac OS 9, Mac OS X
License: Apple EULA (parts available under APSL)
Website: [1]
AppleScript is a scripting language devised by Apple Inc., and built into Mac OS.
..... Click the link for more information.
Developer: Apple Inc.
Latest release: 1.10.7/ 2006-06-30
OS: Mac OS 9, Mac OS X
License: Apple EULA (parts available under APSL)
Website: [1]
AppleScript is a scripting language devised by Apple Inc., and built into Mac OS.
..... Click the link for more information.
A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. Programming languages, like natural languagess, are defined by syntactic and semantic rules which describe their structure and meaning respectively.
..... Click the link for more information.
..... Click the link for more information.
DCL, the DIGITAL Command Language, is the standard command language adopted by most of the operating systems that were sold by the former Digital Equipment Corporation (which has since been acquired by Compaq which itself was acquired by Hewlett-Packard).
..... Click the link for more information.
..... Click the link for more information.
This page is under construction.
This article or section is currently in the middle of an expansion or major revamping. However, you are welcome to assist in its construction by editing it as well.
..... Click the link for more information.
This article or section is currently in the middle of an expansion or major revamping. However, you are welcome to assist in its construction by editing it as well.
..... Click the link for more information.
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
..... Click the link for more information.
..... Click the link for more information.
text file.]]
A text file is a generic description of a kind of computer file in a computer file system.[1] At this generic level of description, there are two kinds of computer files: 1) text files; and 2) binary files.
..... Click the link for more information.
A text file is a generic description of a kind of computer file in a computer file system.[1] At this generic level of description, there are two kinds of computer files: 1) text files; and 2) binary files.
..... Click the link for more information.
MPEG-1 Audio Layer 3
File extension:
MIME type:
Type of format: Audio MPEG-1 Audio Layer 3, more commonly referred to as MP3, is an audio encoding format.
..... Click the link for more information.
File extension:
.mp3MIME type:
audio/mpegType of format: Audio MPEG-1 Audio Layer 3, more commonly referred to as MP3, is an audio encoding format.
..... Click the link for more information.
In computing, the working directory of a process is the directory of a hierarchical file system, if any,[1] which is implicitly used to determine the file referenced to by the process with a file name only, or with a relative path (as opposed to files referenced by full
..... Click the link for more information.
..... Click the link for more information.
In computer file systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the root of a tree - the starting point where all branches originate.
..... Click the link for more information.
..... Click the link for more information.
- For other meanings of 'wild card' see wild card.
The term wildcard character has the following meanings:
Telecommunication
In telecommunications, a wildcard character..... Click the link for more information.
In computer science, pattern matching is the act of checking for the presence of the constituents of a given pattern. In contrast to pattern recognition, the pattern is rigidly specified. Such a pattern concerns conventionally either sequences or tree structures.
..... Click the link for more information.
..... Click the link for more information.
variable (IPA pronunciation: [ˈvæɹiəbl]) (sometimes called a pronumeral) is a symbolic representation denoting a quantity or expression.
..... Click the link for more information.
..... Click the link for more information.
Environment variables are a set of dynamic values that can affect the way running processes will behave on a computer.
..... Click the link for more information.
Synopsis
In all Unix and Unix-like systems, each process has its own private set of environment variables...... Click the link for more information.
A domain-specific programming language (domain-specific language, DSL) is a programming language designed for, and intended to be useful for, a specific kind of task.
..... Click the link for more information.
..... Click the link for more information.
prologue comments indicated in red and inline comments in green. Program code is in blue.]]
In computer programming, a comment is a programming language construct used to embed information in the source code of a computer program.
..... Click the link for more information.
In computer programming, a comment is a programming language construct used to embed information in the source code of a computer program.
..... Click the link for more information.
In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code.
..... Click the link for more information.
..... Click the link for more information.
This article is copied from an article on Wikipedia.org - the free encyclopedia created and edited by online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of the wikipedia encyclopedia articles provide accurate and timely information please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.
Herod_Archelaus