0

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!

1 Answer 1

1

From help read:

  -a array  assign the words read to sequential indices of the array
        variable ARRAY, starting at zero

...

read -a someArray
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.