I have a large number of files that each contain a bash command with a variable amount of parameters. I need to replace these with a corresponding API call.
Example bash command in file (Note: number of '-p' arguments vary, some have none):
./some_script.sh http://some.server.com -p a=value -p b=value -p c=value
Example corresponding API call
http://some.server.com/api/some/endpoint?a=value&b=value&c=value
My issue is I can't seem to group each parameter, given that the number of parameters is variable.
Basic regex (this will match above example, but only group first parameter):
.\/some_script.sh\s([\w\/:\.]*)(\s-\w\s[\w=]*)
And I tried:
.\/some_script.sh\s([\w\/:\.]*)(\s-\w\s[\w=]*)*
However, this seems to only group the last parameter. (tested with regex101)
Ideally, I would like this regex to be able to group an indefinite number of arguments in these files so that I can easily rebuild the command as an API call.
If more detail is required please let me know, any suggestions are welcome.
