Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does readonly mean or do in this case? I have never seen or heard of it.

a="testString"; b=a; readonly b; b=25;

Also, would the final value of b at the end be 25?

share|improve this question
run it and see it.it will help you for sure in the long way. – user917279 Nov 1 '13 at 8:50

It makes the variable read only. From help readonly:

readonly: readonly [-aAf] [name[=value] ...] or readonly -p
    Mark shell variables as unchangeable.

    Mark each NAME as read-only; the values of these NAMEs may not be
    changed by subsequent assignment.  If VALUE is supplied, assign VALUE
    before marking as read-only.

      -a    refer to indexed array variables
      -A    refer to associative array variables
      -f    refer to shell functions
      -p    display a list of all readonly variables and functions

    An argument of `--' disables further option processing.

    Exit Status:
    Returns success unless an invalid option is given or NAME is invalid.

$b would still return "a". As an example:

$ a=1
$ a=2
$ readonly b=1
$ b=2
bash: b: readonly variable
$ echo "$b"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.