Read only variables

The Shell provides a way to mark variables as read-only by using the readonly command. After a variable is marked readonly, its value cannot be changed.

 

For example, the following script generates an error while trying to change the value of the bike variable:

 

 

Invoke:

sh ro.sh

 

Output:

Ducati Desmosedici
ro.sh: line 6: bike: readonly variable