Bash

From XPUB & Lens-Based wiki
Revision as of 19:31, 14 July 2009 by Michael Murtaugh (talk | contribs) (→‎Fundamental Concepts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

BASH Scripting

BASH is the program that is the command line itself. BASH stands for the "Bourne-Again" Shell, the default shell for Linux and Mac OS X (Bourne-again in reference an original UNIX shell written by Stephen Bourne; BASH is a free software rewrite, part of the GNU project).

BASH scripts are, in the simplest form, just a sequence of command line commands saved in a file (or files). In this way, you can save a complicated series of steps in a single file (or BASH script). Using variables, you can turn a script into a tool that can, for instance, be applied to different input files, or perform an image transformation to a variable degree.

Fundamental Concepts

The BASH has most of the standard features of a programming language, including:

Key Terms

Shell:: The program that is running while you use the command line (or the Terminal on a Mac)
BASH:: The "Bourne-Again" Shell
Environment Variables:: The variables (named pieces of text information) that the shell uses to keep track of important system settings. It was the Bourne shell that first added a notion of variables, a crucial step in making the shell a programming environment.
echo:: The BASH command to display something (the "print" statement of the shell)
$PATH:: The environment variable that tells the system where to find programs. When you type a command, the shell will search the places listed in the PATH. (The path contents are a list of UNIX directories separated by colons (:))
Dot-files:: Files that start with a period (.). They are usually hidden (but you can see them with the ls -a command). Usually dot-files are used to store special settings for an application. The shell uses several (like the .profile where you can put shell commands that happen when you start your shell -- though this may depend on which shell program you use).

Resources

Good set of tutorials for BASH scripting.

"Speaking UNIX" on IBM's developerWorks (more general UNIX command line intro) http://www-128.ibm.com/developerworks/aix/library/au-unix-commandline/index.html

Related pages

MediaBashing MoreMediaBashing ["grep"]