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:



bike="Ducati Desmosedici"
readonly bike
echo $bike
bike="Yamaha M1"
echo $bike






Ducati Desmosedici line 6: bike: readonly variable