help-bash
[Top][All Lists]
Advanced

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

Is it possible to use a hash variable in a for-loop?


From: Peng Yu
Subject: Is it possible to use a hash variable in a for-loop?
Date: Wed, 18 Nov 2020 17:16:47 -0600

Hi,

The following examples shows that a hash variable array[x] can not be
used in a for-loop. I think that if a regular variable can be
supported, a hash variable may be supported, too. Can this feature be
added? Or I have not used the correct syntax of this feature? Thanks.

$ declare -A array; for array[x] in a b c; do echo ${array[x]}; done
-bash: `array[x]': not a valid identifier

-- 
Regards,
Peng



reply via email to

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