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

Variables

Korn shell variable names can begin with an alphabetic (a–Z) or underscore character, followed by one or more alphanumeric (a–Z, 0–9) or underscore characters. Other variable names that contain only digits (0–9) or special characters (!, @, #, %, *, ?, $) are reserved for special parameters set directly by the Korn shell.

To assign a value to a variable, you can simply name the variable and set it to a value. For example, to assign abc to variable X:

					$ X=abc
				

The typeset command can also be used to assign values, but unless you are setting attributes, it's a lot more work for nothing. If a value is not given, the variable is set to null. Here, X is reassigned the null value:

					$ X=
				

This is not the same as being undefined. As we'll ...

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