#!/bin/bash array=(aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm) g=4 for((i=0; i < ${#array[@]}; i+=g)) do part=( "${array[@]:i:g}" ) echo "Elements in this group: ${part[*]}" done