3 Shell Variables
3 Shell Variables
must be made executable using chmod (see previous discussion). Then it can be invoked in the same way as any other command, i.e., by typing the script file name on the command line. The -f option says that we want fast startup, which it will achieve by not reading or executing the commands in .cshrc Thus for example, we won't have the `set' values for shell variables or the aliases from that file, but if we don't need them, this will be much faster (if we need a few of them, we can simply add them to the script file itself).
3 Shell Variables
Like other programming languages the csh language has variables. Some variables are used to control the operation of the shell, such as $path and $history, which we discussed earlier. Other variables can be created and used to control the operation of a shell script file.
will set the variable $X to have an empty list as its value. The command
set V = abc
will set V to have the string `abc' as its value. The command
set V = (123 def ghi)
will set V to a list of three elements, which are the strings `123', `def' and `ghi'. The several elements of a list can be treated like array elements. Thus for V in the last example above, $V[2] is the string `def'. We could change it, say to `abc', by the command
set V[2] = abc
The value of a shell variable can be referenced by placing a $ before the name of the variable. The command
echo $path