while { this[i]!="" | that[j]!="" ){ echo "this[i] loves that[j]"; i++;j++; } here is some example in bash that might help #!/bin/sh FOO=( bar string 'some text') foonum=${#FOO} for ((i=0;i<$foonum;i++)); do echo ${FOO[${i}]} done produces -->> bar string some text