[Wolves] Bash nesting arrays

Simon Burke simonb at fatsportsman.eu
Wed Jan 6 14:36:36 UTC 2016

Hi everyone,

I thought I'd post this, as I'm sure there is a better way. Plus I know
there are going to be responses of doing this in something other than bash.
So if someone can tell me a more efficient way of doing this, I’d be

I currently have a need to use an array, where each element has 3
sub-elements. My current idea (that does work) is a little bit botched, but
I'm sure there is going to be a better way to do this.

Seeing that this script keeps getting exponentially larger, I'm going to
have to rewrite it in python at some point. But my python is still lacking,
as I'm managing to do most things in bash and the odd snippet of perl.

The current iteration is the following:
(none of individual elements should have a comma, so using a comma to

ARRAY=(1,2,3 4,5,6 7,8,9)

for i in "${ARRAY[@]}"
      FIRST=($(echo $i |cut -d"," -f1))
      echo "a = $FIRST"

      SECOND=($(echo $i |cut -d"," -f2))
      echo "b = $SECOND"

      THIRD=($(echo $i |cut -d"," -f3))
      echo "c = $THIRD"


Im also aware that not everyone like that I generally use all caps for
variable names. I understand why, but old habits die hard.

More information about the Wolves mailing list