30.13. Pass History to Another ShellMost shells can save a history of the commands you type (Section 30.12). You can add your own commands to some shells' history lists without retyping them. Why would you do that?
Unfortunately, this isn't easy to do in all shells. For instance, the new pdksh saves its history in a file with NUL-separated lines. And the tcsh history file has a timestamp-comment before each saved line, like this: #+0972337571 less 1928.sgm #+0972337575 vi 1928.sgm #+0972337702 ls -lt | head Let's look at an example for two of the shells that make history editing easy. 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: % 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: % 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 (Section 30.14) on the saved commands. -- JP Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|