Go to the first, previous, next, last section, table of contents.


C-Shell Style Features

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

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}}

Tilde 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'
~-/foo
`$OLDPWD/foo'

Bash will also tilde expand words following redirection operators and words following `=' in assignment statements.

C Shell Builtins

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
Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) 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, starting with zero) to the top of the list by rotating the stack.
-n
Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
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] [-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
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.
-n
Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
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
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.
-c
Clears the directory stack by deleting all of the elements.
-l
Produces a longer listing; the default listing format uses a tilde to denote the home directory.
-p
Causes dirs to print the directory stack with one entry per line.
-v
Causes 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 arg
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. Options, if supplied, have the following meanings:
-w
Write out the current history to the history file.
-r
Read the current history file and append its contents to the history list.
-a
Append the new history lines (history lines entered since the beginning of the current Bash session) to the history file.
-n
Append the history lines not already read from the history file to the current history list. These are lines appended to the history file since the beginning of the current Bash session.
-c
Clear the history list. This may be combined with the other options to replace the history list completely.
-s
The args are added to the end of the history list as a single entry.
-p
Perform history substitution on the args and display the result on the standard output, without storing the results in the history list.
When the `-w', `-r', `-a', or `-n' option is used, if filename is given, then it is used as the history file. If not, then the value of the HISTFILE variable is used.
logout
Exit a login shell.
source
A synonym for . (see section Bourne Shell Builtins).

C Shell Variables

IGNOREEOF
If this variable is set, its value is used the number of consecutive EOFs 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.