Use set to set up your own shell variables.
#! /bin/csh
set a=hello
set b="hello world"
set c=(This variable has five elements)
echo $a
echo $b
echo $c
hello
hello world
This variable has five elements
a is a standard shell variable, b is a string
variable. It is possible to determine the number of elements of a shell
variable with the # operator.
echo $#b
1
echo $#c
5
To access the elements of an array variable, use $variable_name[element].
echo $c[3]
has
The dollar sign placed in front of a shell variable allows access to the actual value of the variable, for example
#! /bin/csh
set message=hello
set message2="$message world"
echo $message2
hello world
Individual elements of a shell variable can also be accessed using the following:
Variable, Value(s)
$?name
name not set, 1 if name
set
#name
name
$name[1-3]
name
$name[2-]
name
$name[*]
name
$name
name
Use the @ command, for example
#! /bin/csh
set i = 10
set j = 3
@ k = $i + $j
echo $k
13
#! /bin/csh
@ z = ($i / $j) * 2
echo $z
6
The space after the @ is vital, it separates the name of
the command from its arguments. The arithmetic operators must have a space
before and after them also.
Argument, Meaning
$0
$1
$2
$3 for 3rd etc.)
$*
$#argv
$argv[0]
$argv[1]
$argv[2]
$argv
$$
$<