Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash split array into chunks

#!/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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #split #array #chunks
ADD COMMENT
Topic
Name
3+5 =