1 .\" Copyright (c) 1980, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)csh.2 8.1 (Berkeley) 6/8/93
33 .\" $FreeBSD: src/bin/csh/USD.doc/csh.2,v 1.7.2.1 2001/07/22 11:32:15 dd Exp $
34 .\" $DragonFly: src/bin/csh/USD.doc/csh.2,v 1.2 2003/06/17 04:22:49 dillon Exp $
38 Details on the shell for terminal users
40 Shell startup and termination
42 When you login, the shell is started by the system in your
44 directory and begins by reading commands from a file
47 All shells which you may start during your terminal session will
49 We will later see what kinds of commands are usefully placed there.
50 For now we need not have this file and the shell does not complain about
55 executed after you login to the system,
56 will, after it reads commands from
58 read commands from a file
60 also in your home directory.
61 This file contains commands which you wish to do each time you login
62 to the \s-2UNIX\s0 system.
65 file looks something like:
68 set mail=(/usr/spool/mail/bill)
69 echo "${prompt}users" ; users
71 \'set noglob ; eval \`tset \-s \-m dialup:c100rv4pna \-m plugboard:?hp2621nl \!*\`\';
72 ts; stty intr ^C kill ^U crt
73 set time=15 history=10
81 This file contains several commands to be executed by \s-2UNIX\s0
85 command which is interpreted directly by the shell. It sets the shell
88 which causes the shell to not log me off if I hit ^D. Rather,
91 command to log off of the system.
94 variable, I ask the shell to watch for incoming mail to me. Every 5 minutes
95 the shell looks for this file and tells me if more mail has arrived there.
96 An alternative to this is to put the command
102 this will cause me to be notified immediately when mail arrives, and to
103 be shown the first few lines of the new message.
105 Next I set the shell variable `time' to `15' causing the shell to automatically
106 print out statistics lines for commands which execute for at least 15 seconds
107 of \s-2CPU\s+2 time. The variable `history' is set to 10 indicating that
108 I want the shell to remember the last 10 commands I type in its
114 ``ts'' which executes a
115 \fItset\fR\|(1) command setting up the modes of the terminal.
118 indicate the kinds of terminal which I usually use when not on a hardwired
119 port. I then execute ``ts'' and also use the
121 command to change the interrupt character to ^C and the line kill
124 I then run the `msgs' program, which provides me with any
125 system messages which I have not seen before; the `\-f' option here prevents
126 it from telling me anything if there are no new messages.
127 Finally, if my mailbox file exists, then I run the `mail' program to
130 When the `mail' and `msgs' programs finish, the shell will finish
133 file and begin reading commands from the terminal, prompting for each with
135 When I log off (by giving the
138 will print `logout' and execute commands from the file `.logout'
139 if it exists in my home directory.
140 After that the shell will terminate and \s-2UNIX\s0 will log
142 If the system is not going down, I will receive a new login message.
143 In any case, after the `logout' message the shell is committed to terminating
144 and will take no further input from my terminal.
148 The shell maintains a set of
150 We saw above the variables
154 which had values `10' and `15'.
155 In fact, each shell variable has as value an array of
158 Shell variables may be assigned values by the set command. It has
159 several forms, the most useful of which was given above and is
164 Shell variables may be used to store values which are to
165 be used in commands later through a substitution mechanism.
166 The shell variables most commonly referenced are, however, those which the
167 shell itself refers to.
168 By changing the values of these variables one can directly affect the
169 behavior of the shell.
171 One of the most important variables is the variable
173 This variable contains a sequence of directory names where the shell
174 searches for commands.
177 command with no arguments
178 shows the value of all variables currently defined (we usually say
181 The default value for path will be shown by
190 path (. /usr/ucb /bin /usr/bin)
199 This output indicates that the variable path points to the current
200 directory `.' and then `/usr/ucb', `/bin' and `/usr/bin'.
201 Commands which you may write might be in `.' (usually one of
203 Commands developed at Berkeley, live in `/usr/ucb'
204 while commands developed at Bell Laboratories live in `/bin' and `/usr/bin'.
206 A number of locally developed programs on the system live in the directory
208 If we wish that all shells which we invoke to have
209 access to these new programs we can place the command
211 set path=(. /usr/ucb /bin /usr/bin /usr/local)
215 in our home directory.
216 Try doing this and then logging out and back in and do
220 again to see that the value assigned to
224 Another directory that might interest you is /usr/new, which contains
225 many useful user-contributed programs provided with Berkeley Unix.
228 One thing you should be aware of is that the shell examines each directory
229 which you insert into your path and determines which commands are contained
230 there. Except for the current directory `.', which the shell treats specially,
231 this means that if commands are added to a directory in your search path after
232 you have started the shell, they will not necessarily be found by the shell.
233 If you wish to use a command which has been added in this way, you should
238 to the shell, which will cause it to recompute its internal table of command
239 locations, so that it will find the newly added command.
240 Since the shell has to look in the current directory `.' on each command,
241 placing it at the end of the path specification usually works equivalently
242 and reduces overhead.
244 Other useful built in variables are the variable
246 which shows your home directory,
248 which contains your current working directory,
251 which can be set in your
253 file to tell the shell not to exit when it receives an end-of-file from
254 a terminal (as described above).
255 The variable `ignoreeof'
256 is one of several variables which the shell does not care about the
257 value of, only whether they are
261 Thus to set this variable you simply do
269 These give the variable `ignoreeof' no value, but none is desired or required.
271 Finally, some other built-in shell variables of use are the
280 which redirects the standard output of a command
281 will overwrite and destroy the previous contents of the named file.
282 In this way you may accidentally overwrite a file which is valuable.
283 If you would prefer that the shell not overwrite files in this
295 would cause a diagnostic if `now' existed already.
300 if you really wanted to overwrite the contents of `now'.
301 The `>!' is a special metasyntax indicating that clobbering the
304 \(dgThe space between the `!' and the word `now' is critical here, as `!now'
305 would be an invocation of the
307 mechanism, and have a totally different effect.
310 The shell's history list
312 The shell can maintain a
314 into which it places the words
315 of previous commands.
316 It is possible to use a notation to reuse commands or words
317 from commands in forming new commands.
318 This mechanism can be used to repeat previous commands or to
319 correct minor typing mistakes in commands.
321 The following figure gives a sample session involving typical usage of the
322 history mechanism of the shell.
333 "bug.c", line 4: newline in string or char constant
334 "bug.c", line 5: syntax error
357 a.out: 2784+364+1028 = 4176b = 0x1050b
358 bug: 2784+364+1028 = 4176b = 0x1050b
361 \(mirwxr\(mixr\(mix 1 bill 3932 Dec 19 09:41 a.out
362 \(mirwxr\(mixr\(mix 1 bill 3932 Dec 19 09:42 bug
366 spp: Command not found.
371 4 printf("hello\en");
374 num bug.c | ssp | lpr
378 In this example we have a very simple C program which has a bug (or two)
379 in it in the file `bug.c', which we `cat' out on our terminal. We then
380 try to run the C compiler on it, referring to the file again as `!$',
381 meaning the last argument to the previous command. Here the `!' is the
382 history mechanism invocation metacharacter, and the `$' stands for the last
383 argument, by analogy to `$' in the editor which stands for the end of the line.
384 The shell echoed the command, as it would have been typed without use of
385 the history mechanism, and then executed it.
386 The compilation yielded error diagnostics so we now run the editor on the
387 file we were trying to compile, fix the bug, and run the C compiler again,
388 this time referring to this command simply as `!c', which repeats the last
389 command which started with the letter `c'. If there were other
390 commands starting with `c' done recently we could have said `!cc' or even
391 `!cc:p' which would have printed the last command starting with `cc'
392 without executing it.
394 After this recompilation, we ran the resulting `a.out' file, and then
395 noting that there still was a bug, ran the editor again. After fixing
396 the program we ran the C compiler again, but tacked onto the command
397 an extra `\-o bug' telling the compiler to place the resultant binary in
398 the file `bug' rather than `a.out'. In general, the history mechanisms
399 may be used anywhere in the formation of new commands and other characters
400 may be placed before and after the substituted commands.
402 We then ran the `size' command to see how large the binary program images
403 we have created were, and then an `ls \-l' command with the same argument
404 list, denoting the argument list `\!*'.
405 Finally we ran the program `bug' to see that its output is indeed correct.
407 To make a numbered listing of the program we ran the `num' command on the file `bug.c'.
408 In order to compress out blank lines in the output of `num' we ran the
409 output through the filter `ssp', but misspelled it as spp. To correct this
410 we used a shell substitute, placing the old text and new text between `^'
411 characters. This is similar to the substitute command in the editor.
412 Finally, we repeated the same command with `!!', but sent its output to the
415 There are other mechanisms available for repeating commands. The
417 command prints out a number of previous commands with numbers by which
418 they can be referenced. There is a way to refer to a previous command
419 by searching for a string which appeared in it, and there are other,
420 less useful, ways to select arguments to include in a new command.
421 A complete description of all these mechanisms
422 is given in the C shell manual pages in the \s-2UNIX\s0 Programmer's Manual.
428 mechanism which can be used to make transformations on input commands.
429 This mechanism can be used to simplify the commands you type,
430 to supply default arguments to commands,
431 or to perform transformations on commands and their arguments.
432 The alias facility is similar to a macro facility.
433 Some of the features obtained by aliasing can be obtained also
434 using shell command files, but these take place in another instance
435 of the shell and cannot directly affect the current shells environment
436 or involve commands such as
438 which must be done in the current shell.
440 As an example, suppose that there is a new version of the mail program
441 on the system called `newmail'
442 you wish to use, rather than the standard mail program which is called
444 If you place the shell command
450 file, the shell will transform an input line of the form
454 into a call on `newmail'.
455 More generally, suppose we wish the command `ls' to always show
456 sizes of files, that is to always do `\-s'.
465 creating a new command syntax `dir'
466 which does an `ls \-s'.
471 then the shell will translate this to
478 mechanism can be used to provide short names for commands,
479 to provide default arguments,
480 and to define new short commands in terms of other commands.
481 It is also possible to define aliases which contain multiple
482 commands or pipelines, showing where the arguments to the original
483 command are to be substituted using the facilities of the
487 alias cd \'cd \e!* ; ls \'
491 command after each change directory
494 We enclosed the entire alias definition in `\'' characters to prevent
495 most substitutions from occurring and the character `;' from being
496 recognized as a metacharacter.
497 The `!' here is escaped with a `\e' to prevent it from being interpreted
498 when the alias command is typed in.
499 The `\e!*' here substitutes the entire argument list to the pre-aliasing
501 command, without giving an error if there were no arguments.
502 The `;' separating commands is used here
503 to indicate that one command is to be done and then the next.
504 Similarly the definition
506 alias whois \'grep \e!^ /etc/passwd\'
508 defines a command which looks up its first argument in the password file.
511 The shell currently reads the
513 file each time it starts up. If you place a large number of commands
514 there, shells will tend to start slowly. A mechanism for saving the shell
515 environment after reading the \fI\&.cshrc\fR file and quickly restoring it is
516 under development, but for now you should try to limit the number of
517 aliases you have to a reasonable number... 10 or 15 is reasonable,
518 50 or 60 will cause a noticeable delay in starting up shells, and make
519 the system seem sluggish when you execute commands from within the editor
522 More redirection; >> and >&
524 There are a few more notations useful to the terminal user
525 which have not been introduced yet.
527 In addition to the standard output, commands also have a
528 .I "diagnostic output"
529 which is normally directed to the terminal even when the standard output
530 is redirected to a file or a pipe.
531 It is occasionally desirable to direct the diagnostic output along with
533 For instance if you want to redirect the output of a long running command
534 into a file and wish to have a record of any error diagnostic it produces
539 The `>&' here tells the shell to route both the diagnostic output and the
540 standard output into `file'.
541 Similarly you can give the command
545 to route both standard and diagnostic output through the pipe
546 to the line printer daemon
549 \(dd A command of the form
554 exists, and is used when
561 Finally, it is possible to use the form
565 to place output at the end of an existing file.\(dg
569 is set, then an error will result if
571 does not exist, otherwise the shell will create
579 makes it not be an error for file to not exist when
584 Jobs; Background, Foreground, or Suspended
586 When one or more commands
587 are typed together as a pipeline or as a sequence of commands separated by
590 is created by the shell consisting of these commands together as a unit.
591 Single commands without pipes or semicolons create the simplest jobs.
592 Usually, every line typed to the shell creates a job.
593 Some lines that create jobs (one per line) are
596 ls \-s | sort \-n | head \-5
600 If the metacharacter `&' is typed
601 at the end of the commands, then the job is started as a
603 job. This means that the shell does not wait for it to complete but
604 immediately prompts and is ready for another command. The job runs
605 .I "in the background"
606 at the same time that normal jobs, called
608 jobs, continue to be read and executed by the shell one at a time.
615 program, which reports on the disk usage of your working directory (as well as
616 any directories below it), put the output into the file `usage' and return
617 immediately with a prompt for the next command without out waiting for
621 program would continue executing in the background
622 until it finished, even though you can type and execute more commands in the
625 job terminates, a message is typed by the shell just before the next prompt
626 telling you that the job has completed.
627 In the following example the
629 job finishes sometime during the
632 command and its completion is reported just before
640 How do you know when a background job is finished?
643 [1] \- Done du > usage
647 If the job did not terminate normally the `Done' message might say
648 something else like `Killed'.
650 terminations of background jobs to be reported at the time they occur
651 (possibly interrupting the output of other foreground jobs), you can set
654 variable. In the previous example this would mean that the
655 `Done' message might have come right in the middle of the message to
657 Background jobs are unaffected by any signals from the keyboard like
658 the \s-2STOP\s0, \s-2INTERRUPT\s0, or \s-2QUIT\s0 signals mentioned earlier.
660 Jobs are recorded in a table inside the shell until they terminate.
661 In this table, the shell remembers the command names, arguments and the
663 of all commands in the job as well as the working directory where the job was
665 Each job in the table is either running
666 .I "in the foreground"
667 with the shell waiting for it to terminate, running
668 .I "in the background,"
671 Only one job can be running in the foreground at one time, but several
672 jobs can be suspended or running in the background at once. As each job
673 is started, it is assigned a small identifying
676 which can be used later to refer to the job in the commands described below.
678 the same until the job terminates and then are re-used.
680 When a job is started in the backgound using `&', its number, as well
681 as the process numbers of all its (top level) commands, is typed by the shell
682 before prompting you for another command.
685 % ls \-s | sort \-n > usage &
689 runs the `ls' program with the `\-s' options, pipes this output into
690 the `sort' program with the `\-n' option which puts its output into the
692 Since the `&' was at the end of the line, these two programs were started
693 together as a background job. After starting the job, the shell prints
694 the job number in brackets (2 in this case) followed by the process number
695 of each program started in the job. Then the shell immediates prompts for
696 a new command, leaving the job running simultaneously.
698 As mentioned in section 1.8, foreground jobs become
701 which sends a \s-2STOP\s0 signal to the currently running
702 foreground job. A background job can become suspended by using the
704 command described below. When jobs are suspended they merely stop
705 any further progress until started again, either in the foreground
706 or the backgound. The shell notices when a job becomes stopped and
707 reports this fact, much like it reports the termination of background jobs.
708 For foreground jobs this looks like
715 `Stopped' message is typed by the shell when it notices that the
718 For background jobs, using the
726 [1] + Stopped (signal) sort usage
730 Suspending foreground jobs can be very useful when you need to temporarily
731 change what you are doing (execute other commands) and then return to
732 the suspended job. Also, foreground jobs can be suspended and then
733 continued as background jobs using the
735 command, allowing you to continue other work and
736 stop waiting for the foreground job to finish. Thus
745 starts `du' in the foreground, stops it before it finishes, then continues
746 it in the background allowing more foreground commands to be executed.
747 This is especially helpful
748 when a foreground job ends up taking longer than you expected and you
749 wish you had started it in the backgound in the beginning.
753 commands can take an argument that identifies a particular
755 All job name arguments begin with the character `%', since some of the
756 job control commands also accept process numbers (printed by the
759 The default job (when no argument is given) is called the
761 job and is identified by a `+' in the output of the
763 command, which shows you which jobs you have.
764 When only one job is stopped or running in the background (the usual case)
765 it is always the current job thus no argument is needed.
766 If a job is stopped while running in the foreground it becomes the
768 job and the existing current job becomes the
770 job \- identified by a `\-' in the output of
772 When the current job terminates, the previous job becomes the current job.
773 When given, the argument is either `%\-' (indicating
774 the previous job); `%#', where # is the job number;
775 `%pref' where pref is some unique prefix of the command name
776 and arguments of one of the jobs; or `%?' followed by some string found
777 in only one of the jobs.
781 command types the table of jobs, giving the job number,
782 commands and status (`Stopped' or `Running') of each backgound or
783 suspended job. With the `\-l' option the process numbers are also
788 % ls \-s | sort \-n > myfile &
795 [1] \(mi Running du > usage
796 [2] Running ls \-s | sort \-n > myfile
797 [3] \(pl Stopped mail bill
799 ls \-s | sort \-n > myfile
806 command runs a suspended or background job in the foreground. It is
807 used to restart a previously suspended job or change a background job
808 to run in the foreground (allowing signals or input from the terminal).
809 In the above example we used
811 to change the `ls' job from the
812 background to the foreground since we wanted to wait for it to
813 finish before looking at its output file.
816 command runs a suspended job in the background. It is usually used
817 after stopping the currently running foreground job with the
818 \s-2STOP\s0 signal. The combination of the \s-2STOP\s0 signal and the
820 command changes a foreground job into a background job.
823 command suspends a background job.
827 command terminates a background or suspended job immediately.
828 In addition to jobs, it may be given process numbers as arguments,
831 Thus, in the example above, the running
833 command could have been terminated by the command
837 [1] Terminated du > usage
844 command (not the variable mentioned earlier) indicates that the termination
845 of a specific job should be
846 reported at the time it finishes instead of waiting for the next prompt.
848 If a job running in the background tries to read input from the terminal
849 it is automatically stopped. When such a job is then run in the
850 foreground, input can be given to the job. If desired, the job can
851 be run in the background again until it requests input again.
852 This is illustrated in the following sequence where the `s' command in the
853 text editor might take a long time.
858 1,$s/thisword/thatword/
864 . . . some foreground commands
866 [1] Stopped (tty input) ed bigfile
875 So after the `s' command was issued, the `ed' job was stopped with ^Z
876 and then put in the background using
878 Some time later when the `s' command was finished,
880 tried to read another command and was stopped because jobs
881 in the backgound cannot read from the terminal. The
883 command returned the `ed' job to the foreground where it could once again
884 accept commands from the terminal.
890 causes all background jobs run on your terminal to stop
891 when they are about to
892 write output to the terminal. This prevents messages from background
893 jobs from interrupting foreground job output and allows you to run
894 a job in the background without losing terminal output. It also
895 can be used for interactive programs that sometimes have long
896 periods without interaction. Thus each time it outputs a prompt for more
897 input it will stop before the prompt. It can then be run in the
900 more input can be given and, if necessary stopped and returned to
903 command might be a good thing to put in your
905 file if you do not like output from background jobs interrupting
906 your work. It also can reduce the need for redirecting the output
907 of background jobs if the output is not very big:
913 \&. . . some time later
916 [1] Stopped (tty output) wc hugefile
923 Thus after some time the `wc' command, which counts the lines, words
924 and characters in a file, had one line of output. When it tried to
925 write this to the terminal it stopped. By restarting it in the
926 foreground we allowed it to write on the terminal exactly when we were
927 ready to look at its output.
928 Programs which attempt to change the mode of the terminal will also
929 block, whether or not
931 is set, when they are not in the foreground, as
932 it would be very unpleasant to have a background job change the state
937 command only prints jobs started in the currently executing shell,
938 it knows nothing about background jobs started in other login sessions
939 or within shell files. The
941 can be used in this case to find out about background jobs not started
942 in the current shell.
946 As mentioned in section 1.6, the shell is always in a particular
947 .I "working directory."
948 The `change directory' command
954 changes the working directory of the shell,
955 that is, changes the directory you
958 It is useful to make a directory for each project you wish to work on
959 and to place all files related to that project in that directory.
960 The `make directory' command,
962 creates a new directory.
965 (`print working directory') command
966 reports the absolute pathname of the working directory of the shell,
967 that is, the directory you are
969 Thus in the example below:
979 the user has created and moved to the
982 where, for example, he might
983 place a group of related files.
985 No matter where you have moved to in a directory hierarchy,
986 you can return to your `home' login directory by doing just
991 The name `..' always means the directory above the current one in
996 changes the shell's working directory to the one directly above the
998 The name `..' can be used in any
1004 change to the directory `programs' contained in the directory
1005 above the current one.
1006 If you have several directories for different
1007 projects under, say, your home directory,
1008 this shorthand notation
1009 permits you to switch easily between them.
1011 The shell always remembers the pathname of its current working directory in
1014 The shell can also be requested to remember the previous directory when
1015 you change to a new working directory. If the `push directory' command
1017 is used in place of the
1019 command, the shell saves the name of the current working directory
1021 .I "directory stack"
1022 before changing to the new one.
1023 You can see this list at any time by typing the `directories'
1028 % pushd newpaper/references
1029 ~/newpaper/references ~
1030 % pushd /usr/lib/tmac
1031 /usr/lib/tmac ~/newpaper/references ~
1033 /usr/lib/tmac ~/newpaper/references ~
1035 ~/newpaper/references ~
1040 The list is printed in a horizontal line, reading left to right,
1042 shorthand for your home directory\(emin this case `/usr/bill'.
1043 The directory stack is printed whenever there is more than one
1044 entry on it and it changes.
1045 It is also printed by a
1049 is usually faster and more informative than
1051 since it shows the current working directory as well as any
1052 other directories remembered in the stack.
1056 command with no argument
1057 alternates the current directory with the first directory in the
1061 command without an argument returns you to the directory you were in prior to
1062 the current one, discarding the previous current directory from the
1063 stack (forgetting it).
1066 several times in a series takes you backward through the directories
1067 you had been in (changed to) by
1070 There are other options to
1074 to manipulate the contents of the directory stack and to change
1075 to directories not at the top of the stack; see the
1077 manual page for details.
1079 Since the shell remembers the working directory in which each job
1080 was started, it warns you when you might be confused by restarting
1081 a job in the foreground which has a different working directory than the
1082 current working directory of the shell. Thus if you start a background
1083 job, then change the shell's working directory and then cause the
1084 background job to run in the foreground, the shell warns you that the
1085 working directory of the currently running foreground job is different
1086 from that of the shell.
1102 ed prog.c (wd: ~/myproject)
1104 This way the shell warns you when there
1105 is an implied change of working directory, even though no cd command was
1106 issued. In the above example the `ed' job was still in `/mnt/bill/project'
1107 even though the shell had changed to `/mnt/bill'.
1108 A similar warning is given when such a foreground job
1109 terminates or is suspended (using the \s-2STOP\s0 signal) since
1110 the return to the shell again implies a change of working directory.
1113 ed prog.c (wd: ~/myproject)
1114 . . . after some editing
1119 These messages are sometimes confusing if you use programs that change
1120 their own working directories, since the shell only remembers which
1121 directory a job is started in, and assumes it stays there.
1124 will type the working directory
1125 of suspended or background jobs when it is different
1126 from the current working directory of the shell.
1128 Useful built-in commands
1130 We now give a few of the useful built-in commands of the shell describing
1135 command described above is used to assign new aliases and to show the
1137 With no arguments it prints the current aliases.
1138 It may also be given only one argument such as
1142 to show the current alias for, e.g., `ls'.
1146 command prints its arguments.
1149 or as an interactive command
1150 to see what filename expansions will produce.
1154 command will show the contents of the history list.
1155 The numbers given with the history events can be used to reference
1156 previous events which are difficult to reference using the
1157 contextual mechanisms introduced above.
1158 There is also a shell variable called
1160 By placing a `!' character in its value the shell will there substitute
1161 the number of the current command in the history list.
1162 You can use this number to refer to this command in a history substitution.
1165 set prompt=\'\e! % \'
1167 Note that the `!' character had to be
1169 here even within `\'' characters.
1173 command is used to restrict use of resources.
1174 With no arguments it prints the current limitations:
1179 datasize 5616 kbytes
1180 stacksize 512 kbytes
1181 coredumpsize unlimited
1184 Limits can be set, e.g.:
1186 limit coredumpsize 128k
1188 Most reasonable units abbreviations will work; see the
1190 manual page for more details.
1194 command can be used to terminate a login shell which has
1200 command causes the shell to recompute a table of where commands are
1201 located. This is necessary if you add a command to a directory
1202 in the current shell's search path and wish the shell to find it,
1203 since otherwise the hashing algorithm may tell the shell that the
1204 command wasn't in that directory when the hash table was computed.
1208 command can be used to repeat a command several times.
1209 Thus to make 5 copies of the file
1215 repeat 5 cat one >> five
1221 to set variables in the environment.
1226 will set the value of the environment variable \s-2TERM\s0
1231 exists which will print out the environment.
1237 PATH=:/usr/ucb:/bin:/usr/bin:/usr/local
1245 command can be used to force the current shell to read commands from
1251 can be used after editing in a change to the
1253 file which you wish to take effect right away.
1257 command can be used to cause a command to be timed no matter how much
1258 \s-2CPU\s0 time it takes.
1261 % time cp /etc/rc /usr/bill/rc
1262 0.0u 0.1s 0:01 8% 2+1k 3+2io 1pf+0w
1263 % time wc /etc/rc /usr/bill/rc
1265 52 178 1347 /usr/bill/rc
1267 0.1u 0.1s 0:00 13% 3+3k 5+3io 7pf+0w
1272 command used a negligible amount of user time (u)
1273 and about 1/10th of a system time (s); the elapsed time was 1 second (0:01),
1274 there was an average memory usage of 2k bytes of program space and 1k
1275 bytes of data space over the cpu time involved (2+1k); the program
1276 did three disk reads and two disk writes (3+2io), and took one page fault
1277 and was not swapped (1pf+0w).
1278 The word count command
1280 on the other hand used 0.1 seconds of user time and 0.1 seconds of system
1281 time in less than a second of elapsed time.
1282 The percentage `13%' indicates that over the period when it was active
1283 the command `wc' used an average of 13 percent of the available \s-2CPU\s0
1284 cycles of the machine.
1290 commands can be used
1291 to remove aliases and variable definitions from the shell, and
1293 removes variables from the environment.
1297 This concludes the basic discussion of the shell for terminal users.
1298 There are more features of the shell to be discussed here, and all
1299 features of the shell are discussed in its manual pages.
1300 One useful feature which is discussed later is the
1302 built-in command which can be used to run the same command
1303 sequence with a number of different arguments.
1305 If you intend to use \s-2UNIX\s0 a lot you should look through
1306 the rest of this document and the csh manual pages (section1) to become familiar
1307 with the other facilities which are available to you.