Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

XENIX Programming csh: C Shell Using Built-In Commands This section explains how to use some of the built-in C shell commands. The alias command (see "Using Aliases" above) is used to assign new aliases and to display existing aliases. If given no arguments, alias prints the list of current aliases. alias can also be given one argument to show the current alias for a given string of characters. For example alias Is prints the current alias for the string "Is". The history command displays the contents of the history list. The numbers given with the history events can be used to reference previous events difficult to reference contextually. There is also a C shell variable named prompt. By placing an exclamation point (!) in its value the C shell will substitute the nu mber of the current command in the history list. You can use this nu mber to refer to a command in a history substitution. For example, you could type set prompt = I \ ! % I Nate that the exclamation mark (!) had to be escaped even within single quotes. The logout command is used to terminate a login C shell that has ignoreeof set. The rehash command causes the C shell to recompute a table of command locations. This is necessary if you add a command to a directory in the current C shell's search path and want the C shell to find it, since otherwise the hashing algorithm may tell the C shell that the command wasn't in that directory when the hash table was computed. The repeat command is used to repeat a command several times. For example, to make five copies of the file one in the file five you could type repeat 5 cat one > > five The setenv command can be used to set variables in the environment. Thus setenv TERM adm3a sets the value of the environment variable TERM to "adm3a". The env command prints out the environment. For example: % env HOME =/usr/bill SHELL = /bin/csh PATH = :/usr/ucb:/bin:/usr/bi n:/usr/local TERM = adm3a USER = bill 8-9

csh: C Shell XENIX Programming The source command is used to cause the current C shell to read commands from a file until the end of the file. Thus source .cshrc can be used after editing in a change to the .cshrc file that you wish to take effect before the next time you log in. The time command is used to cause a command to be timed no matter how much CPU time it takes. Thus displays Similarly displays time cp /etc/rc /usr/bi 11/rc O.Ou 0.15 0:01 8% time we /etc/rc /usr/bi 11/rc 52 178 1347 /etc/rc 52 178 1347 /usr/bi 1 1/rc 104 356 2694 total 0.1 u 0.15 0:00 13% This indicates that the cp command used a negligible amount of user time (u) and about one-tenth of a second system time (s); the elapsed time was one second (0:0 1). The word count command we used 0.1 seconds of user time and 0.1 seconds of system time in less than a second of elapsed time. The percentage "13%" indicates that over the period when it was active the we command used an average of 13 percent of the available CPU cycles of the machine. The unalias and unset commands are used to remove aliases and variable definitions from the C shell. The command unsetenv removes variables from the environment. Creating Command Scripts You can place commands in files and cause C shells to be invoked to read and execute commands from these files, which are called C shell scripts. This section describes the C shell features that are useful when creating C shell scripts. 8-10

<strong>XENIX</strong> Programming csh: C Shell<br />

Using Built-In Commands<br />

This section explains how to use some of the built-in C shell commands.<br />

The alias command (see "Using Aliases" above) is used to assign new aliases and to<br />

display existing aliases. If given no arguments, alias prints the list of current aliases.<br />

alias can also be given one argument to show the current alias for a given string of<br />

characters. For example<br />

alias Is<br />

prints the current alias for the string "Is".<br />

The history command displays the contents of the history list. The numbers given with<br />

the history events can be used to reference previous events difficult to reference<br />

contextually. There is also a C shell variable named prompt. By placing an exclamation<br />

point (!) in its value the C shell will substitute the nu mber of the current command in<br />

the history list. You can use this nu mber to refer to a command in a history<br />

substitution. For example, you could type<br />

set prompt = I \ ! % I<br />

Nate that the exclamation mark (!) had to be escaped even within single quotes.<br />

The logout command is used to terminate a login C shell that has ignoreeof set.<br />

The rehash command causes the C shell to recompute a table of command locations.<br />

This is necessary if you add a command to a directory in the current C shell's search<br />

path and want the C shell to find it, since otherwise the hashing algorithm may tell the<br />

C shell that the command wasn't in that directory when the hash table was computed.<br />

The repeat command is used to repeat a command several times. For example, to make<br />

five copies of the file one in the file five you could type<br />

repeat 5 cat one > > five<br />

The setenv command can be used to set variables in the environment. Thus<br />

setenv TERM adm3a<br />

sets the value of the environment variable TERM to "adm3a". The env command prints<br />

out the environment. For example:<br />

% env<br />

HOME =/usr/bill<br />

SHELL = /bin/csh<br />

PATH = :/usr/ucb:/bin:/usr/bi n:/usr/local<br />

TERM = adm3a<br />

USER = bill<br />

8-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!