Bash - Readonly Buitlin (Constant variable and function)


The given names are marked readonly; the values of these names may not be changed by subsequent assignment.


readonly [-apf] [name[=word] ...]


  • -f set also the functions corresponding to the names read-only
  • -a restricts the variables to arrays.
  • -p prints a list of all readonly names. The -p option causes output to be displayed in a format that may be reused as input.
  • [name[=word] …] The value of the variable is set to word.

Without options, a list of all readonly names is printed.

The return status is 0 unless:

  • an invalid option is encountered,
  • one of the names is not a valid shell variable name,
  • or -f is supplied with a name that is not a function.

Powered by ComboStrap