mercredi 31 août 2016

bash automatically select specific variable from while

Is there a way to call a variable through the $i in a while loop? To access a specific variable automatically?

This is a scaled down version of what i'm trying to do:

i=1;

while [ $i -lt 4 ]; do
    let card$i=1;
    let i++;
done

let i=1;

while [[ $i -lt 4 ]]; do

    if [ "$card$i" = "1" ]; then 
        let card$i++;
    fi

    let i++;
done

Is there a way to make this work?

(I'm trying to do this with +50 variables. This is just scaled down)

Thanks.

Aucun commentaire:

Enregistrer un commentaire