开源是一种精神,分享是一种美德!

readonly

相关命令:暂无相关命令
readonly命令Shell内建命令 readonly命令用于定义只读shell变量和shell函数。readonly命令的选项-p可以输出显示系统中所有定义的只读变量。 

语法 readonly(选项)(参数) 

选项 

-f:定义只读函数; 
-a:定义只读数组变量; 
-p:显示系统中全部只读变量列表。

[root@localhost fdfs]# readonly       #显示只读变量
declare -r BASHOPTS="checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath"
declare -ir BASHPID=""
declare -ar BASH_VERSINFO='([0]="4" [1]="1" [2]="2" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")'
declare -ir EUID="0"
declare -ir PPID="5306"
declare -r SHELLOPTS="braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor"
declare -ir UID="0"

[root@localhost fdfs]# readonly test="1"      #定义只读变量

[root@localhost fdfs]# test=2        #只读变量不可改
bash: test: readonly variable

评论(0)

暂无评论

评论

名字:
验证码:
获取验证码
内容: