I have been hacking away in bash a little bit lately and it's remarkable how such a simple set of utilities can allow you to perform quite complex tasks.

I had an array of files that I wanted to do some operations on and the following construct allowed me to easily iterate through that list.

FILES=( a/path/to/a/file1 a/path/to/another/file2 and/so/on/and/so/on )

for ELEMENT in $(seq 0 $((${#FILES[@]} - 1))); do
  echo ${FILES[$ELEMENT]}
doneĀ 

The $(seq 0 $(($#FILES[@]} - 1))); returns the number of elements in FILE, the seq command produces a sequence of numbers from x to y. If you call seq 0 4, you will get a line with 0, 1, 2, 3, 4 on it.

So while the syntax is a little smelly, the terse power of it, is quite handy.