test.sh:

#!/bin/bash
myUrl="http://www.google.com"
readonly myUrl
myUrl="http://www.runoob.com"

输出

bogon:Desktop macname$ ./test.sh 
./test.sh: line 4: myUrl: readonly variable

 

参考:

https://www.runoob.com/linux/linux-shell-variable.html

 

相关文章: