Valid Characters

Part of naming variables wisely is knowing which characters are valid characters to be used in the varname. Valid characters for varnames are the letters of the alphabet (both upper- and lowercase), numbers, and the underscore character. One caveat is that the varname cannot start with a number. For example, consider the following varnames:

Peaches
2Peaches
PeachesAndCream
Peaches4
_2Peaches

The second is not a legal varname, but the rest are. Notice that the last example begins with an underscore, which is valid. The second one is not valid because it begins with a number.

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.