I am writing this Bash script:
count=0 result for d in `ls -1 $IMAGE_DIR | egrep \"jpg$\"` do if (( (count % 4) == 0 )); then result=\"a
Something like this (untested, of course):
count=0 result= for d in "$IMAGE_DIR"/*jpg; do (( ++count % 4 == 0 )) && result="abc $d" (( count > 0 )) && printf '%s\n' "$result" || result+=$d done