Reputation: 11
Im new to bash scripting and I'm trying to write a script that asks for filenames and puts them into a variable (for use in an AWS CLI get from Glacier, but that's not important yet).
I want it to be able to read any number of filenames put onto the same line, separated by a space or other delimiter. I can use read to turn multiple inputs into multiple variables, like
read $variable1 $variable2
but only if I know how exactly how many inputs. How do I do it for any number?
Thanks!
Upvotes: 0
Views: 1207
Reputation: 799580
From help read
:
-a array assign the words read to sequential indices of the array
variable ARRAY, starting at zero
...
read -a someArray
Upvotes: 1