bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compou


From: Oğuz
Subject: Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax
Date: Sun, 24 Mar 2024 19:46:46 +0200

On Sunday, March 24, 2024, Zachary Santer <zsanter@gmail.com> wrote:
>
> Yeah, but what can you do with @k?


It helps when reconstructing an associative array as a JSON object in JQ

    $ declare -A a=([x]=1 [y]=2)
    $ jq --args -n '[$ARGS.positional | _nwise(2) | {(.[0]): .[1]}] | add'
"${a[@]@k}"
    {
      "y": "2",
      "x": "1"
    }


-- 
Oğuz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]