Полезная информация Диспорт по материалам сайта.

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 11.11 Picking Up Where You Left Off Chapter 11
The Lessons of History
Next: 11.13 Shell Command-Line Editing
 

11.12 Pass History to Another Shell

The C shell, Korn shell, and bash automatically save a history of the commands you type. You can add your own commands to the csh and bash history lists without retyping them. Why would you do that?

Here's an example. Use the csh command history -h, or the bash command history -w, to save the history from a shell to a file. Edit the file to take out commands you don't want:

C shell   bash

% mail -s "My report" bigboss   $ mail -s "My report" bigboss
    ...       ...
% history -h > history.std   $ history -w history.std
% vi history.std   $ vi history.std
    ...Clean up history...       ...Clean up history...

Read that file into another shell's history list with the csh command source -h or the bash command history -r:

C shell   bash

% source -h history.std   $ history -r history.std
% !ma   $ !ma
mail -s "My report" bigboss   mail -s "My report" bigboss

Of course, you can also use bash interactive command-line editing (11.13) on the saved commands.

- JP


Previous: 11.11 Picking Up Where You Left Off UNIX Power ToolsNext: 11.13 Shell Command-Line Editing
11.11 Picking Up Where You Left Off Book Index11.13 Shell Command-Line Editing

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System