I need to create a bash array from the command line parameters. I only know how to do it when I know the number of parameters. But what do I do when I dont know the number of parameters?
Here is one way of doing it
#!/bin/bash
array=()
while IFS= read -r -p "Enter next item (blank to end input): " element
do
[[ $element ]] || break
array+=("$element")
done
printf "%s " "${array[@]}"
printf "\n"