# Shell Variables
$# | count args
$n | nth arg
$? | last exit code
$! | last pid

# Array
Fruits=('Apple' 'Banana' 'Orange' 'Pear')

echo ${Fruits[0]}           # Element #0
echo ${Fruits[-1]}          # Last element
echo ${Fruits[@]}           # All elements, space-separated
echo ${#Fruits[@]}          # Number of elements
echo ${#Fruits}             # String length of the 1st element
echo ${#Fruits[3]}          # String length of the Nth element
echo ${Fruits[@]:3:2}       # Range (from position 3, length 2)
echo ${!Fruits[@]}          # Keys of all elements, space-separated

Fruits=("${Fruits[@]}" "Grape")         # Push
Fruits+=('Watermelon')                  # Also Push
Fruits=( ${Fruits[@]/Ap*/} )            # Remove by regex match
unset Fruits[2]                         # Remove one item
Fruits=("${Fruits[@]}")                 # Duplicate
Fruits=("${Fruits[@]}" "${Veggies[@]}") # Concatenate

TempFiles=($(ls /tmp))

for i in "${Fruits[@]}"; do
  echo $i
done

if [[ " ${Fruits[*]} " =~ " Banana " ]]; then
  echo "Apple in Fruits"
fi


# Default value
echo ${value:-xa} # xa
value=xyz/ijk/abc

# Head
echo ${value%/*} # xyz/ijk
echo ${value%%/*} # xyz

# Tail
echo ${value#*/} # ijk/abc
echo ${value##*/} # abc

# Truncate
echo ${value:7} # /abc
echo ${value:7:4} # /abc
echo ${value:(-4):4} # /abc

# Replace
echo ${value/abc/cba} # xyz/cba
