nixre.net
== arrays ==

Arrays in bash have only numbered indexes.
An entire array can be assigned by enclosing it's intems in parenthesis

array0=( array0s items are here )

STRING='array1s items come from a variable'

array1=( $STRING )


Referring to arrays's items happens this way:

echo "${array0[3]}" # 3 is the last item, so the word 'here'

echo "${array1[0]}"


Special constructs:

${arr[*]}         # All of the items in the array
${!arr[*]}        # All of the indexes in the array
${#arr[*]}      # Number of items in the array
${#arr[0]}      # Length of item zero



"Note that the "@" sign can be used instead of the "*" in constructs such as ${arr[*]},
the result is the same except when expanding to the items of the array within a quoted
string. In this case the behavior is the same as when expanding "$*" and "$@" within quoted strings:
"${arr[*]}" returns all the items as a single word, whereas "${arr[@]}" returns each item as a separate word."



Source of the information so far was: https://www.linuxjournal.com/content/bash-arrays

And there is a little trick to capitalize the first letter of several words.
Put all the words into a bash array, refer to all it's items with * or @
and put a circumflex before the closing curly brace:

WORDS='word0 word1 word2'

ARR=( $WORDS )
echo -e "\n${ARR[@]^}\n"

Word0 Word1 Word2