Viewing Session History in the csh Shell

Viewing Session History in the csh Shell

If you're a C programmer (or have C programmers to turn to for help), csh might be a good shell for you because the syntax is quite similar to the C programming language.csh doesn't offer command completion, but the history capabilities are fairly similar to those of bash or zsh (see Code Listing 3.14). In general, csh is a powerful scripting shell (and acceptable interactive shell) for those who take the time and effort to become familiar with it.

Code Listing 3.14. csh also lets you recycle commands by number, although other history functions are not available.

xmission> history    1  ls    2  vi    3  ls    4  cd pub*    5  ls    6  cp *.pdf ..    7  cd ..    8  rm *.pdf    9  history   10  lynx   11  ftp   12  ls   13  vi .plan   14  finger   15  history   16  finger   17  ls   18  pine   19  history   20  lynx   21  history xmission> !12 ls Desktop  files  tmp  bin  a.out xmission> 

To view session history in the csh shell:


If you haven't already, use the shell for a little while, changing directories, redirecting output, or doing other tasks.



Type history at the shell prompt to see the list of the most recent commands you've entered. Note the number of each command line (Code Listing 3.14).



Type ! followed by the command number (no space in between) to rerun one of the commands. In this example, we're rerunning command 10.


  • See Chapter 8 for how to make csh easier and more productive, particularly if you don't have any other shell options available to you.

  • You can edit commands in the session history. With csh, however, it's far easier to retype the commands than to edit them.

  • If you like csh, check for the availability of tcsh on your system. It's like csh but adds command completion and other similar capabilities that are comparable to bash.

  • Sometimes, the length of the history is set to 0 (keeping no history lines) by default. If your history doesn't seem to work, try set history=100 to save 100 lines of history. Add this to your startup files (next chapter) if you want it to be available every time.

Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: