09.06.2013 Views

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

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

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

The notation<br />

$#name<br />

expands to the number of elements in the variable name. To illustrate, examine the<br />

following terminal session (input is in boldface):<br />

% set argv =(a b c)<br />

1<br />

% echo $#argv<br />

3<br />

% unset argv<br />

% echo $?argv<br />

0<br />

% echo $argv<br />

Undefi ned variable: argv.<br />

%<br />

You can also access the components of a variable that has several values. Thus<br />

$argv[1]<br />

gives the first component of argv or in the example above "a". Similarly<br />

$argv[$#argv]<br />

would give "c", and .<br />

$argv[1-2]<br />

would give "a b". Other notations useful in C shell scripts are<br />

$n<br />

where n is an integer. This is shorthand for<br />

$argv[ n]<br />

the nth parameter and<br />

$*<br />

which is a shorthand for<br />

$argv<br />

The form<br />

$$<br />

expands to the process number of the current C shell. Since this process number is<br />

unique in the system, it is often used in the generation of unique temporary file names.<br />

8-12

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

Saved successfully!

Ooh no, something went wrong!