Here is an simple bash script showing the trick to create the read-only variable, feel free to copy and use this script.
$ cat declare.sh
#!/bin/bash
# Declare the variable as readonly
declare -r AGE=25
echo $AGE
# Try to change the value of this readonly variable
# you should get an error message
AGE=34
echo $AGE
Output: $ ./declare.sh
./declare.sh
25
./declare.sh: line 9: AGE: readonly variable
25
#!/bin/bash
# Declare the variable as readonly
declare -r AGE=25
echo $AGE
# Try to change the value of this readonly variable
# you should get an error message
AGE=34
echo $AGE
Output: $ ./declare.sh
./declare.sh
25
./declare.sh: line 9: AGE: readonly variable
25
source:http://linuxpoison.blogspot.com/2012/05/13578167754992.html