O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The readonly Command

The readonly command sets the value and/or readonly attribute of variables. It is equivalent to the typeset –r command, except that when used within a function, a local variable is not created. This command sets X to readonly and assigns it a value of 1:

					$ readonly X=1
				

This is equivalent to:

					$ typeset —r X=1
				

Multiple variables can be given to the readonly command.

					$ readonly X Y=1 Z=2
				

If no arguments are given, a list of readonly variables and their values is displayed:

					$ readonly
					Z=1
					Y=1
					Z=2
					PPID=175
				

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required