BASH

From TBP Wiki
Revision as of 16:00, 21 June 2019 by Goldbolt (talk | contribs)
Jump to: navigation, search

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. Released in 1989, it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and OS X. It has been ported to Microsoft Windows and distributed with Cygwin and MinGW, to DOS by the DJGPP project, to Novell NetWare and to Android via various terminal emulation applications. In the late 1990s, Bash was a minor player among multiple commonly used shells; at present Bash has overwhelming favor.

Bash is a command processor that typically runs in a text window, where the user types commands that cause actions. Bash can also read commands from a file, called a script. Like all Unix shells, it supports filename globbing (wildcard matching), piping, here documents, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language were all copied from sh. Other features, e.g., history, were copied from csh and ksh. Bash is a POSIX shell, but with a number of extensions.

The name itself is an acronym, a pun, and a description. As an acronym, it stands for Bourne-again shell, referring to its objective as a free replacement for the Bourne shell. As a pun, it expressed that objective in a phrase that sounds similar to born again, a term for spiritual rebirth. The name is also descriptive of what it did, bashing together the features of sh, csh, and ksh.

A security hole in Bash dating from version 1.03 (August 1989), dubbed Shellshock, was discovered in early September 2014.

Conversion

This shows how to convert a .sh file to a one-liner:

   #!/usr/local/bin/bash
   while [ 1 -lt 2 ]
   do
   clear
   date
   echo ------------------------------------
   eval $@
   sleep 2
   done
   while [ 1 -lt 2 ]; do clear; date; echo ------------------------------------; eval $@; sleep 2; done