How to get the keys and values of an associative array indirectly in Bash? -
In the Bash, only one variable is given in which the name of an associative array is,
< Code> $ declare -A dict = ([abc] = 125 [def] = 456) $ dictvar = "dict"How can we get keys and values of associative array?
In the Bash, to get the keys of an associative array via induction, the variable
or
local ():
$ declare -a 'keys = ("$ {
$ {Key [@]}; $ value_var = "$ {dictvar} [$ key]" resonate $ "$ key = $ {value_var}" $ done
< Optional has been suggested using code> eval . According to
, this function completed thanks to a new
declare -n in Bash 4.3+ Easy to do That variable can solve a variable name in the variable.
Comments
Post a Comment