How do I create n variables in shell scripts without explicitly assigning them? What I mean is something like a loop that creates var1
, var2
, var3
,...,varx
, where x
is a variable I set earlier, something like:
read x
for ((a=0;a<x;++a)); do
variable$a=${RANDOM}
done
(Let's ignore the possibility that x
might be a string for now. But obviously, this doesn't work. How would one do this?
What I actually want to do, is that each argument I wrote in the command line when I executed the script to become it's own variable ARG1
, ARG2
... ARGn
with ${1}
, ${2}
,..., ${n}
as its value, so there will only be as many of these variables, as arguments were set.