0

I'll like to convert an array of strings in this format ["1.2.1","1.9.2"] to ("1.2.1" "1.9.2") using a bash script.

I tried this

${MY_TAGS//[[\], .!]}

I got this

'100101'

What I'll like as output in

("1.2.1" "1.9.2")
11
  • Out of curiosity: what's motivating the transformation? Looks like a JSON literal for the input, not sure of the output. Are you trying to make a list of arguments for a function / script? Commented Jul 10, 2023 at 13:10
  • 2
    If you have an array of strings, please show how you created it instead of describing it in words. Commented Jul 10, 2023 at 13:10
  • Note that array=( "one" "two" ) is a way to define a bash array with the literal items one and two -- the (s, the "s, &c aren't actually part of the array itself, they're just the definition syntax. Right now we don't know if you want parens and quotes in output, or you want an array defined the same way it would be if you had used that syntax. Commented Jul 10, 2023 at 13:19
  • I'll like to iterate over it. I got it from an az acr repository show-tags command Commented Jul 10, 2023 at 13:20
  • If the actual situation is that you have a JSON array and you want to populate a native bash array from it, that's a different and simpler question (at least, as long as you're willing to use tools like jq that understand JSON). Commented Jul 10, 2023 at 13:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.