linux - Bash declaring variable with a number inside a for loop -
this question has answer here:
- dynamic variable names in bash 6 answers
i can't find answer problem, other people asking use array instead. that's not want. want declare number of variables inside loop same name except index number.
i=0 int in $ints; i=[$i +1]; intf$i=$int; done
it doesn't work. when run script thinks middle part intf$i=$int
command.
without array, need use declare
command:
i=0 int in $ints; i=$((i +1)) declare "intf$i=$int" done
with array:
intf=() int in $ints; intf+=( $int ) done
Comments
Post a Comment