70 likes | 194 Views
CSCI 330 The UNIX System. Shell History and Directory Stacks. Shell History. shell keeps a record of previously entered commands so that they can later be: Re-executed Edited Commands are saved Per session Per user. Shell History.
E N D
CSCI 330The UNIX System Shell History and Directory Stacks
CSCI 330 - The UNIX System Shell History • shell keeps a record of previously entered commands so that they can later be: • Re-executed • Edited • Commands are saved • Per session • Per user
CSCI 330 - The UNIX System Shell History • Each previously run command gets a sequential event number • To view the history buffer: Syntax: history [-c] [count] • If no options are supplied, list all Useful options: -c clear history
CSCI 330 - The UNIX System Shell History • You can re-execute history events: • By the event number % !5 • By the number relative to current event % !-3 • By the text it contains % !ls
Directory Stacks • To keep track of multiple directories using stack structure • To maintain a directory stack, we use the following three commands: • pushd • popd • dirs CSCI 330 - The UNIX System 5
PUSHD • pushd (with no argument) to travel between two top stack entries • pushd directory to push directory on top of stack • pushd +n to rotate nth entry to the top of stack CSCI 330 - The UNIX System 6
POPD AND DIRS • popd (with no argument) to remove the top directory and changes to the next stack entry • popd +n to remove the nth directory from stack • dirs: to display all directory entries. The top entry is listed at the leftmost position CSCI 330 - The UNIX System 7