4. Arrays

Introduction

# declaring an array
declare -a ary
# declaring + defining
single_level = ( this that the other )
# @@INCOMPLETE@@

Specifying a List In Your Program

# pushing at the end of an array
ary[${#ary[@]}]=whatever
# @@INCOMPLETE@@

Printing a List with Commas

Changing Array Size

Doing Something with Every Element in a List

for element in "${list[@]}"; do
    echo $element
done
# @@INCOMPLETE@@

Iterating Over an Array by Reference

Extracting Unique Elements from a List

Finding Elements in One Array but Not Another

Computing Union, Intersection, or Difference of Unique Lists

Appending One Array to Another

Reversing an Array

Processing Multiple Elements of an Array

Finding the First List Element That Passes a Test

Finding All Elements in an Array Matching Certain Criteria

Sorting an Array Numerically

Sorting a List by Computable Field

Implementing a Circular List

Randomizing an Array

Program: words

Program: permute