Arrays

Think of an array as a structure that can hold more than a single object, something like a variable with one or many values. Imagine you have a few friends and you want to write down their names:

friend_1=Anthonyfriend_2=Mikefriend_3=Noelfriend_4=Tarekfriend_5=Dionysios

Once you have the variables instanced, you can then deference them, deferencing being the act of retrieving a value. This is OK, but it somehow cages you into some limitations, such as you must call the exact variable name to access its value, you cannot easily cycle between them, you cannot tell the number of values so quickly, and more. For such operations, there is an appropriate structure, which comes at hand and allows us to work on the values as a single entity--this ...

Get Mastering Bash 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.