declare : shell, definate the attributes of variables

syntax:

declare [-aixr] var_name

-a   var_name is an array

-i     integer

-x  set var_name as the system variable, the same function as export

-r   readonly variable, cannot change, cannot unset

examples:

$ declare var[1]="setting 1"

$ echo ${var[1]}

setting 1

$ declare var[2]="configuration 2"

$ echo ${var[2]}

configuration 2

$ declare var[3]="defination 3"

$ echo ${var[3]}

defination 3

$ echo "${var[1]},${var[2]},${var[3]}"

setting 1,configuration 2,defination 3

你可能感兴趣的:(declare : shell, definate the attributes of variables)