Possible Duplicate:How do I reverse a for loop? Is there an easy way to invert a for in loop? For a script I want to process files in their reverse order.So instead of:for file in *.jpg;  do echo $file;donewith the result001.jpg002.jpg003.jpg...150.jpgI want the result150.jpg149.jpg148.jpg...001.jpg
Invert results for for in * do-loops
bash;shell script;scripting
You can usearray=(*.jpg)for ((i = ${#array[@]} - 1;i >= 0;i--)); do    echo ${array[i]}done