Previous | Table of Contents | Next |
Define any aliases for the user in the .cshrc file. The syntax for creating an alias is alias alias-name command sequence. For example, you can shortcut the alias command so that you type only the letter a by adding this line to the .cshrc file:
alias a alias
Here are some examples of aliases from a .cshrc file. Note that if the command contains spaces, you enclose the entire command in quotes. In these examples, both double and single quotes are used:
alias a alias a h history a c clear a lf ls -F a ll "ls -l | more" a la ls -a a s "source .cshrc" a f 'find ~ -name core -print' a copytotape "tar cvf /dev/rmt/Ø *"
To set history for the C shell, on a command line type set history=n and press Return. history is set to the number of lines you specify:
oak% set history=1Ø oak%
You can set history temporarily for a shell window or set it "permanently" so that the same history setting is available at each login session by entering the command as a line in your .cshrc file.
To display the history for the C shell, on a command line type history and press Return. The last n commands that you had set for the history are displayed:
oak% history 26 pwd 27 kermit 28 cd Howto 29 tar xvf /dev/rmt/Ø 3Ø ls -l howto* 31 cd 32 cd Config/Art 33 ls -l 34 tar cvf /dev/rmt/Ø 35 history oak%
To repeat the previous command in a C shell, type !! and press Return. The previous command is executed again:
oak% history 26 pwd 27 kermit 28 cd Howto 29 tar xvf /dev/rmt/Ø 3Ø ls -l howto* 31 cd 32 cd Config/Art 33 ls -l 34 tar xvf /dev/rmt/Ø 35 history oak% !! history 27 kermit 28 cd Howto 29 tar xvf /dev/rmt/Ø 3Ø ls -l howto* 31 cd 32 cd Config/Art 33 ls -l 34 tar xvf /dev/rmt/Ø 35 history 36 history oak%
To repeat the last word of the previous command in a C shell, type !$ and press Return. The last word from the previous command is used as part of the command-line argument.
For example, you might list the complete path name of a file, and then use the path name as the argument to edit the file using vi, or to print it:
oak% ls -l /home/ignatz/quest oak% lp !$ lp /home/ignatz/quest oak%
You can use the !$ command anywhere within the command line. In this example, the file /home/ignatz/quest is copied to the /tmp directory:
oak% ls -l /home/ignatz/quest oak% cp !$ /tmp cp /home/ignatz/quest /tmp oak%
To repeat a numbered command in a C shell, type !n and press Return. The number in the shell prompt is n. The command is executed again.
oak% history 29 tar xvf /dev/rmt/Ø 3Ø ls -l howto* 31 cd 32 cd Config/Art 33 ls -l 34 tar xvf /dev/rmt/Ø 35 ls -l 36 cd 37 lp howto* 38 history oak% !32 cd Config/Art oak%
If you want to change the erase key from Delete to Backspace, type stty erase, then press Control and Shift together, and then type H and press Return. The Backspace key is set as the erase key:
oak% stty erase ^H oak%
The C shell builds an internal table of commands named with the path variable. When you add a new command to a directory, the command is not part of the internal table and the shell cannot execute it. To incorporate a new command into the search path internal table, type rehash and press Return. Any new commands are incorporated into your command search path:
oak% newcommand newcommand: Command not found oak% rehash oak% newcommand oak%
You can edit commands retrieved from the history list using the s/oldstring/newstring/ form to substitute in the command as retrieved. In this example, an incorrectly typed command from the history list is corrected:
oak% history 31 cd 32 ls 33 cd /home/frame3.1 34 ls 35 cd .. 36 tar cvf /dev/rmt/Ø frame3.1 37 lp questionnaire 38 lpstat -t 39 echo $PaTH 4Ø history oak% !39:s/a/A/ echo $PATH .:/home/winsor:/usr/openwin/bin:/usr/deskset/bin:/home/ winsor/bin:/bin:/home/bin:/etc:/usr/etc:/usr/bin:/home/frame3.1/bin oak%
The Korn shell, developed by David Korn of AT&T Bell Laboratories, is a superset of the Bourne shell. That is, the Korn shell uses the same syntax as the Bourne shell, but it has more built-in functions that can be defined directly from the shell. The Korn shell provides a more sophisticated form of command editing than does the C shell. The Korn shell also provides a command history and aliases.
The Korn shell provides a complete command and programming language. The following sections provide a brief introduction to some of the most basic features of the Korn shell.
Previous | Table of Contents | Next |