#!/bin/bash
# testing the difference between "${arr[*]}" and "${arr[@]}"
# (that is, when these are quoted)
# by: Mitch Frazier, http://www.linuxjournal.com/content/bash-arrays
# (adapted by Sharon Tuttle)
# last modified: 10-18-12
pets=(dog "brat cat" minnow "peruvian bat-eared booger dog")
echo "=========================================="
echo "Number of items in original array: ${#pets[*]}"
echo "=========================================="
echo 'using ${pets[*]} (UNquoted):'
for item in ${pets[*]}
do
echo $item
done
echo "=========================================="
echo 'using ${pets[@]} (UNquoted):'
for item in ${pets[@]}
do
echo $item
done
echo "=========================================="
echo 'using "${pets[*]}" (quoted):'
for item in "${pets[*]}"
do
echo $item
done
echo "=========================================="
echo 'using "${pets[@]}" (quoted):'
for item in "${pets[@]}"
do
echo $item
done
echo "=========================================="