|
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 COMMAND.COM (DOS) and cmd.exe (Windows) command line scripts are usually called batch files, but here properties of both are discussed. Scripting languages (commonly called scripting programming languages or script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard. ...
In computing, a shell is a piece of software that provides an interface for users (command line interpreter). ...
It has been suggested that this article or section be merged into Command line interface. ...
An operating system (OS) is the software that manages the sharing of the resources of a computer. ...
A domain-specific programming language (domain-specific language, DSL) is a programming language designed to be useful for a specific set of tasks. ...
Screenshot of a sample Bash session, taken on Gentoo Linux. ...
COMMAND.COM is the name for the default operating system shell (or command line interpreter) for DOS and 16/32bits versions of Windows (95/98/98 SE/Me). ...
This article is about the family of closely related operating systems for the IBM PC compatible platform. ...
This article needs additional references or sources for verification. ...
âWindowsâ redirects here. ...
Wikibooks has more about this subject: Guide to Windows commands 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. ...
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 or the graphical Windows Script Host (WScript.exe), 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. This article or section does not adequately cite its references or sources. ...
Windows PowerShell, previously Microsoft Shell or MSH (codenamed Monad) is an extensible command line interface (CLI) shell and scripting language product developed by Microsoft. ...
Microsofts disk operating system, MS-DOS, was Microsofts implementation of DOS, which was the first popular operating system for the IBM PC, and until recently, was widely used on the PC compatible platform. ...
AppleScript is a scripting language devised by Apple, Inc. ...
The Microsoft Windows Script Host (originally called Windows Scripting Host, but renamed for the second release) is distributed and installed by default on Windows 98 and later versions of Microsoft Windows. ...
A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...
DCL is the standard Command line interface (CLI) adopted by most of the operating systems that were sold by the former Digital Equipment Corporation (which has since been acquired by Hewlett-Packard). ...
Job Control Language (JCL) is a scripting language used on IBM mainframe operating systems to instruct the Job Entry Subsystem (that is, JES2 or JES3) on how to run a batch program or start a subsystem. ...
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: 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. ...
Computer files can be divided into two broad categories: binary and text. ...
For other uses, see MP3 (disambiguation). ...
For computer operating systems that support a hierarchial file system, the working directory is the directory path that a user or program has designated to be the directory for files referenced by name only, or by a relative path (as contrasted with using both a files name and a...
In computer file systems, the root directory is the first or top-most directory in a hierarchy. ...
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. The term wildcard character has the following meanings: // In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters. ...
In computer science, pattern matching is the act of checking for the presence of the constituents of a given pattern. ...
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": In computer science and mathematics, a variable (IPA pronunciation: ) (sometimes called a pronumeral) is a symbolic representation denoting a quantity or expression. ...
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. Environment variables are a set of dynamic values that can affect the way running processes will behave on a computer. ...
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. General-purpose programming language or General purpose Softwares refers to a type software that is suitable for most ordinary computer applications. ...
An illustration of Java source code with prologue comments indicated in red and inline comments in green. ...
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. ...
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. Scripting languages (commonly called scripting programming languages or script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard. ...
A high-level programming language is a programming language that, in comparison to low-level programming languages, may be more abstract, easier to use, or more portable across platforms. ...
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. Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. ...
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). A filter is a computer program to process a data stream. ...
A fork, when applied to computing occurs when a process creates a copy of itself, which then acts as a child of the original process, now called the parent. More generally, a fork in a multithreading environment means that a thread of execution is duplicated. ...
Quotes It is easier to port a shell than a shell script. -- Larry Wall Larry Wall Larry Wall (born September 27, 1954) is a programmer, linguist, and author, most widely known for his creation of the Perl programming language in 1987. ...
See also 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 Microsoft Windows Script Host (originally called Windows Scripting Host, but renamed for the second release) is distributed and installed by default on Windows 98 and later versions of Microsoft Windows. ...
In computing, a shebang is a specific pair of characters used in a special line that begins a text file (commonly called a script) causing Unix-like operating systems to execute the commands in the text file using a specified interpreter (program) when executed. ...
External links Wikibooks has a book on the topic of Ad Hoc Data Analysis From The Unix Command Line |