
hier ist ein Beispielcode
astr[10]=a
astr[20]=b
astr[30]=b
astrR="astr[@]"
echo ${!astr[@]} #the indexes
echo ${!astrR} #the values
#FAIL: echo ${!!astrR}
astrR="!astr[@]" # wild guess
echo ${!astrR} # empty output, so I am still wild
Wie erhält man also die Indizes mithilfe von astrR
?
Antwort1
declare -n astrR="astr"
von Tipps hier:https://unix.stackexchange.com/a/390763/30352
(hauptsächlich beantwortet, um nicht unbeantwortet zu bleiben und unnötige Aufmerksamkeit von anderen Fragen abzulenken, die eine Antwort benötigen)