I am in the middle of writing a bash script. The pending point I am stuck with is how to accept multiple inputs from the user at a time.
To be specific, a user must be able to input multiple domain names when the script asks to enter the input.
Example, script running portion:
Enter the domain names :
Yes, you can: use
printf "Enter the domain names: " readarray -t arr # Do something... declare -p arr
The last line above just documents what bash now sees as the array.
The user can type or copy-and-paste the array names. When the user is done, he types Ctrl-D at the beginning of a line.
$ bash script Enter the domain names: domain1.com domain2.com domain3.com domain4.com declare -a arr='(="domain1.com" ="domain2.com" ="domain3.com" ="domain4.com")'