I was wondering if there is an easy way in bash to break up a large array into several smaller ones. I currently am thinking something like this:
for ((i = 0; i<= (bigArrayLength/2); i++)) do
bigArray[i] = smallArray[i]
done
for ((i = (bigArrayLength/2); i <=bigArrayLength; i++))
do
bigArray[i] = secondSmallArray[i]
done
But there has to be a better way to go about it. Any suggestions? Thanks!
smallArray=("${bigArray[@]:0:$cnt1}")
and it will be OK with spaces in the elements. Also, slicing is supported in Bash 3.2 as well as 4. – Hermosillo