Array

A simple definition for an array is that it is a single variable (varname) that can store one or more values. The Korn shell has two types of arrays: indexed and associative.

In an indexed array, each element of the array is indexed with an arithmetic expression. The index is valid as long as the value of the arithmetic expression is at least zero. The upper value of the arithmetic expression is dependent on the implementation, but in all versions of Linux and UNIX, it is at least 4,095.

NOTE

On a sample Red Hat Linux 6.1 system, a simple program to increment an indexed array had a memory fault after 13088. This means that 13,088 values were stored in one array before a memory error caused the system to crash the program.

In an associative ...

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.