Bash Reference Manual
Taken from man pages but reworded, rearranged and examples to make it so even I can see how to do something with bash!
A user interface, command language interpreter,
a shell, a macro processor that executes commands.
The term macro processor means functionality where text and symbols are expanded to create larger expressions.
Files containing commands can be treated as commands. Those files with the same name as system commands are executed instead of the system command.
- Command Line Editing
if then elif else fi
for do done
DGG made this nice stuff from, what is now, and old version of the docs.
The truth is out there
> bash --help # as of 7/28/16
GNU bash, version 4.1.2(1)-release-(x86_64-redhat-linux-gnu)
Usage: bash [GNU long option] [option] ...
bash [GNU long option] [option] script-file ...
GNU long options:
--init-file --login --noediting --noprofile --norc --rcfile
--posix --restricted --protected --rpm-requires
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Type `bash -c "help set"' for more information about shell options.
Type `bash -c help' for more information about shell builtin commands.
following rearranged, i.e. not exactly as displayed
> sh -c "help set"
set: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
Set the variable corresponding to option-name:
- Assign any remaining arguments to the positional parameters.
|Mark variables which are modified or created for export.
|the shell will perform brace expansion
|Exit immediately if a command exits with a non-zero status.
|ERR trap is inherited by shell functions.
|If set, the DEBUG trap is inherited by shell functions.
|Remember the location of commands as they are looked up.
| enable command history
|Enable ! style history substitution. default on when shell is interactive.
|the shell will not exit upon reading EOF
|All assignment arguments are placed in the environment for a command,
not just those that precede the command name.
|disallow existing regular files to be overwritten by redirection of output.
|Disable file name generation (globbing).
| Job control is enabled.
|Notify of job termination immediately.
|Treat unset variables as an error when substituting.
|Exit after reading and executing one command.
|do not follow symbolic links when executing commands such as
cd which change the current directory.
| the return value of a pipeline is the status of
the last command to exit with a non-zero status,
or zero if no command exited with a non-zero status
|Turned on whenever the real and effective user ids do not match.
Disables processing of the $ENV file and importing of shell functions.
Turning this option off causes the effective uid and gid to be set to
the real uid and gid.
| use a vi-style line editing
| use an emacs-style line editing
|Read commands but do not execute them.
|display shell input lines as they are read.
|display commands and arguments as they are executed.
|operate as 1003.2 standard
|allow comments to appear in interactive commands
-v are turned off.
Using + rather than - causes flags to be turned off.
The flags can be used at invocation of the shell.
The current set of flags may be found ina
echo $- himBH (hashall, jobcontrol, Braceexpand, HistExpand )
The remaining n ARGs are positional parameters and are assigned, in order, to
$1, $2, &hellipo; $n.
If no ARGs are given, all variables are printed.
sh -c help for more information about shell builtin commands.
OS X has an older version of bash. It does not include newer versions,
as well as several other commands (including:
becuse they have a GPL V3 license that explicitly restricts commercial Unix vendors from including them.
Where there is an open source command you are allowed to install it. Package managers that can add them include: Homebrew, MacPorts, Fink.
BASH_VERSION=GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
> ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Nov 20 2014 /bin/sh -> bash
BASH_VERSION=3.2.57 @OS X El Capitan ⌘ :
> /bin/sh -c 'echo -e "Hello\n\tWorld"'
> /bin/bash -c 'echo -e "Hello\n\tWorld"'
Severly hacked by Dennis G German beginning 12/18/01 and continuing today
Since then sub versions up to -53 exist( these do not change functionally but correct bugs