Thursday, May 3, 2007

Unchanging variables: readonly

Sometime a need may arise for variables to have a constant or fixed value.
A very simple script to state the same.

$ cat
readonly a
echo $a
echo "Trying to set \"a\" to a diff value"
echo $a

A Sample run:
Trying to set "a" to a diff value
readonly: line 6: a: readonly variable

From the shell the readonly variables can be listed using "readonly" command.

No comments:

© Jadu Saikia