2

How to change a command line argument in Bash? explains how to modify input arguments in bash.

But in my case, I have a dynamic set of input arguments. I don't know how many are there.

This is my command:

send url key1=value1 key2=value2 key3=value3

I want to change all of the = signs to : automatically. And the key=value pairs are not limited.

How can I do that?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Mohammad Miras
  • 143
  • 1
  • 9

1 Answers1

5

Here you go:

set -- "${@/=/:}"

This replaces, in every positional parameter, the first equals sign with a colon.

See Assigning to a positional parameter for further information on the set command.

oguz ismail
  • 1
  • 16
  • 47
  • 69