So I am trying to parse input arrays for every nth element to then create new arrays for use within the bash script. Is this possible? If so could someone please provide an example. Thanks!
parseArray(){
#passing args through $x where x is arg no, 0 reserved for function
n=$1 #every nth element
in=$2 #input array
out=$3 #output array
for ((i=n-1; i<${#in[@]}; i+=n)); do
out+=("in[@]");
done
}
inputArray=(.....)
newArray=() #declaring empty array to change
parseArray 2 inputArray newArray #invoking function
echo ${newArray[@]} #printing new edited array