Go to the previous, next section.

C Shell Builtins

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)

  • Go to the previous, next section.