lundi 29 août 2016

Bash Automatically while loop variable

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

This is what i mean:

i=1;
card1=1;
card2=1;
card3=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?

Thanks.

Aucun commentaire:

Enregistrer un commentaire