Skip to content
Advertisement

how to handle bash with multiple arguments for multiple options

I need to download chart data from poloniex rest client with multiple options using bash only. I tried getopts but couldn’t really find a way to use mutliple options with multiple parameters.

here is what I want to achieve

JavaScript

having the arguments I need to call wget for c x p times

JavaScript

well I am explicitly writing my ultimate goal as probably many others looking for it nowadays.

Advertisement

Answer

Could something like this work for you?

JavaScript

You can then call your script like this:

JavaScript

The output for the above will be:

JavaScript

Update

You can use the same option multiple times. When parsing the argument values, you can then add them to an array.

JavaScript

You can then call your script as follows:

JavaScript

The output will be:

JavaScript

Reference: BASH: getopts retrieving multiple variables from one flag

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement