Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Source Link

Transform an array into arguments of a command?

I have an array of "options" of a command.

my_array=(option1 option2 option3)

I want to call this command in a bash script, using the values from array as options. So, command $(some magic here with my_array) "$1" becomes:

command -option1 -option2 -option3 "$1"

How can I do it? Is it possible?