|
Go to the previous, next chapter.
The C-Shell (csh) was created by Bill
Joy at UC 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 for controlling the interactive behaviour of the shell
(e.g. IGNOREEOF).
Using History Interactively for details on history expansion.
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.
- ~ The current value of
$HOME. ~/foo $HOME/foo
~fred/foo The subdirectory foo of
the home directory of the user fred.
~+/foo $PWD/foo
~- $OLDPWD/foo
Bash will also tilde expand words following redirection
operators and words following = in assignment
statements.
Brace expansion is a mechanism by which arbitrary strings may
be generated. This mechanism is similar to pathname
expansion (see the Bash manual page for details), 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,
a{d,c,b}e
expands into 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 several builtin commands whose definition is very
similar to csh.
- pushd
pushd [dir | +n | -n]
Save the current directory on a list and then cd
to dir. With no arguments, exchanges the top
two directories.
- +n Brings the nth
directory (counting from the left of the list printed by
dirs)
to the top of the list by rotating the stack.
- -n Brings the nth
directory (counting from the right of the list printed by
dirs)
to the top of the list by rotating the stack.
- dir Makes the current working directory
be the top of the stack, and then cds to dir.
You can see the saved directory list with the
dirs
command.
- popd
popd [+n | -n]
Pops the directory stack, and cds to the
new top directory. When no arguments are given, removes
the top directory from the stack and cds 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 Removes the nth
directory (counting from the left of the list printed by
dirs),
starting with zero.
- -n Removes the nth
directory (counting from the right of the list printed by
dirs),
starting with zero.
- dirs
dirs [+n | -n] [-l]
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 Displays the nth
directory (counting from the left of the list printed by
dirs
when invoked without options), starting with zero.
- -n Displays the nth
directory (counting from the right of the list printed by
dirs
when invoked without options), starting with zero.
- -l Produces a longer listing;
the default listing format uses a tilde to denote the
home directory.
- history
history [n] [ [-w -r -a -n] [filename]]
Display 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. Option -w means write out the current
history to the history file; -r means to
read the current history file and make its contents the
history list. An argument of -a means to
append the new history lines (history lines entered since
the beginning of the current Bash session) to the history
file. Finally, the -n argument means to read
the history lines not already read from the history file
into the current history list. These are lines appended
to the history file since the beginning of the current
Bash session. If filename is given, then it is
used as the history file, else if $HISTFILE
has a value, that is used, otherwise ~/.bash_history
is used.
- logout Exit a login shell.
- source A synonym for
. (see section Bourne Shell Builtins)
-
- IGNOREEOF If this variable is set, it represents
the number of consecutive
EOFs Bash will
read before exiting. By default, Bash will exit upon
reading a single EOF.
- cdable_vars If this variable is set, Bash treats
arguments to the
cd command which are not
directories as names of variables whose values are the
directories to change to.
To return to the Ready-to-Run Software Win95Pak Table of Contents please press here.
|