Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
8 user(s) are online (7 user(s) are browsing encyclopedia)

Members: 0
Guests: 8

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Bash

: This article is about the Unix shell named Bash. For other meanings of Bash see Bash (disambiguation).

Bash is a Unix shell written for the GNU project. Its name is an acronym for Bourne-again shell —a pun on the Bourne shell (sh), which was an early, important Unix shell. The Bourne shell was the shell distributed with Version 7 Unix, circa 1978. The original Bourne shell was written by Stephen Bourne, then a researcher at Bell Labs. The Bash shell was written in 1987 by Brian Fox. In 1990, Chet Ramey became the primary maintainer. Bash is the default shell on most Linux systems as well as on Mac OS X v10.4, and it can be run on most Unix-like operating systems. It has also been ported to Microsoft Windows by the Cygwin project.

=Bash syntax highlights=

Bash s command syntax is a superset of the Bourne shell s command syntax. The definitive specification of Bash s command syntax is the [http://www.gnu.org/software/bash/manual/bashref.html Bash Reference Manual] distributed by the GNU project. This section highlights some of Bash s unique syntax features.

The vast majority of Bourne shell scripts can be executed without alteration by Bash, with the exception of those Bourne shell scripts that happen to reference a Bourne special variable or to use a Bourne builtin command. The Bash command syntax includes ideas drawn from the Korn shell (ksh) and the C shell (csh), such as command-line editing, command history, the directory stack, the $RANDOM and $PPID variables, and POSIX command substitution syntax: $(...). When being used as an interactive command shell, Bash supports completion of partly typed-in program names, filenames, variable names, etc. when the user presses the TAB key.

Bash syntax has many extensions that the Bourne shell lacks. Several of those extensions are enumerated here.

==Integer mathematics==

A major limitation of the Bourne shell is that it cannot perform integer calculations without spawning an external process. Bash can perform in-process integer calculations using the command and the $[...] variable syntax, as follows:

VAR=55 # Assign integer 55 to variable VAR. # Add one to variable VAR. Note the absence of the $ character. # Another way to add one to VAR. Performs C-style pre-increment. # Another way to add one to VAR. Performs C-style post-increment. echo $[VAR * 22] # Multiply VAR by 22 and substitute the result into the command. echo $ # Another way to do the above.

The command can also be used in conditional statements, because its exit status is 0 or 1 depending on whether the condition is true or false:

if then echo Yes fi && echo Yes

The command supports the following relational operators: == , != , > , < , >= , and <= .

Bash cannot perform in-process floating point calculations. The only Unix command shells capable of this are Korn Shell (1993 version) and zsh (starting at version 4.0).

==I/O redirection==

Bash has several I/O Redirection (Unix) syntaxes that the traditional Bourne shell lacks. Bash can redirect standard output and Standard streams at the same time using this syntax:

command &> file

which is simpler to type than the equivalent Bourne shell syntax, command > file 2>&1 . Bash, since version 2.05b, can redirect standard input from a string using the following syntax (sometimes called here strings ):

command test.data # produce some content echo data:data:data # close file test.data exec 1>&- # make stdout a copy of FD 6 (reset stdout) exec 1>&6 # close FD6 exec 6>&-

Open and close files

# open file test.data for reading exec 6