The C-Shell (csh
) was created by Bill Joy at The
University of California at Berkeley. It
is generally considered to have better features for interactive use than
the original Bourne shell. Some of the csh
features present in
Bash include job control, history expansion, `protected' redirection, and
several variables to control the interactive behaviour of the shell
(e.g., IGNOREEOF
).
See section Using History Interactively, for details on history expansion.
Brace expansion is a mechanism by which arbitrary strings may be generated. This mechanism is similar to filename expansion (see section Filename Expansion), but the file names generated need not exist. Patterns to be brace expanded take the form of an optional preamble, followed by a series of comma-separated strings between a pair of braces, followed by an optional postamble. The preamble is prepended to each string contained within the braces, and the postamble is then appended to each resulting string, expanding left to right.
Brace expansions may be nested. The results of each expanded string are not sorted; left to right order is preserved. For example,
bash$ echo a{d,c,b}e ade ace abe
Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved in the result. It is strictly textual. Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces.
A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma. Any incorrectly formed brace expansion is left unchanged.
This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example:
mkdir /usr/local/src/bash/{old,new,dist,bugs}
or
chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
Bash has tilde (~) expansion, similar, but not identical, to that of
csh
. The following table shows what unquoted words beginning
with a tilde expand to.
~
$HOME
.
~/foo
~fred/foo
foo
of the home directory of the user
fred
.
~+/foo
~-/foo
Bash will also tilde expand words following redirection operators and words following `=' in assignment statements.
Bash has several builtin commands whose definition is very similar
to csh
.
pushd
pushd [dir | +N | -N] [-n]Save the current directory on a list and then
cd
to
dir. With no
arguments, exchanges the top two directories.
+N
dirs
, starting with zero) to the top of
the list by rotating the stack.
-N
dirs
, starting with zero) to the top of
the list by rotating the stack.
-n
dir
cd
s to dir. You can see the saved directory list
with the dirs
command.
popd
popd [+N | -N] [-n]Pop the directory stack, and
cd
to the new top directory. When
no arguments are given, popd
removes the top directory from the stack and
performs a cd
to the new top directory. The
elements are numbered from 0 starting at the first directory listed with
dirs
; i.e., popd
is equivalent to popd +0
.
+N
dirs
), starting with zero.
-N
dirs
), starting with zero.
-n
dirs
dirs [+N | -N] [-clvp]Display the list of currently remembered directories. Directories find their way onto the list with the
pushd
command; you can get
back up through the list with the popd
command.
+N
dirs
when invoked without options), starting
with zero.
-N
dirs
when invoked without options), starting
with zero.
-c
-l
-p
dirs
to print the directory stack with one entry per
line.
-v
dirs
to print the directory stack with one entry per
line, prepending each entry with its index in the stack.
history
history [-c] [n] history [-anrw] [filename] history -ps argDisplay the history list with line numbers. Lines prefixed with with a `*' have been modified. An argument of n says to list only the last n lines. Options, if supplied, have the following meanings:
-w
-r
-a
-n
-c
-s
-p
HISTFILE
variable is used.
logout
source
.
(see section Bourne Shell Builtins).
IGNOREEOF
EOF
s Bash will read before exiting. By default, Bash will exit
upon reading a single EOF
. If IGNOREEOF
is not set to
a numeric value, Bash acts as if its value were 10.
Go to the first, previous, next, last section, table of contents.