machine_name> history
to obtain a numbered list of previous commands. To select the nth one, type:
machine_name> !n
To repeat the last command, type !!. To repeat the command before the last, type !-2. One may also recall commands using the first characters from those commands. To repeat the last command starting with the character v, type !v. To repeat the last command that started with more, type !more.
Every C Shell command can be abbreviated by using the alias command. After typing
machine_name> alias h history
machine_name> alias ll ls -l
h is equivalent to history and ll is equivalent to ls -l.
In the Math Department we use an enhanced C shell, called the TC shell. This allows another means of repeating commands. You may press the arrow keys (to the right of the Shift and Ctrl keys on your keyboard) to get previous or next commands. For example, to see the last command you entered, just press the up-arrow key once. To see the command you entered the time before last, press the up-arrow twice. If you now choose to go back down the the last command, press the down-arrow.
machine_name> cat myfile > yourfile
has the same function as cp myfile yourfile. By itself, the command cat myfile would cause the contents of myfile to be listed on the screen. Here the > symbol tells UNIX to write the output (the listing) on a file called yourfile. If yourfile already exists, its contents are destroyed. If it does not exist, it is created.
Frequently you will not want to destroy an existing file, but will want to append the contents of another file on the end of it. For this, the >> symbol is used. The command
machine_name> cat myfile >> yourfile
appends the contents of myfile to the end of the file yourfile. If yourfile does not exist, it is created. It is also possible to redirect input using the < symbol, but this will not be discussed further here.
machine_name> ls papers | more
One may start a job in the background immediately. To do so, simply type the command to start the program, followed by an ampersand ( & ). For example, to run Mosaic in the background while leaving your screen available for other things, type
machine_name> mosaic &
The following commands check on the process status of a program called myprog, and then kill it (This might occur if it's taking too long to execute - you might think that it is in an infinite loop).
machine_name> ps
PID TT STAT TIME COMMAND
5185 p1 I 0:00 -csh
6120 p1 I 0:59 myprog
The only commands entered from the keyboard were the first and last lines. The lines in between are the output from the ps command. The -9 flag on the kill command allows it to kill almost any job. You cannot kill someone elses job. Never kill the csh command, since that represents your current session.
If you try to log out, but the computer won't let you, saying that "there are stopped jobs", all you should have to do is type fg, and then kill the program that is stopped. After that, you should be able to log out. There are a number of other ways to use this feature to advantage.
Back to the on line help page
| Webmaster |