o*****l 发帖数: 539 | 1 请教大侠们一个问题, 谢谢!
Is it possible to use bash to implement a data structure like
Map> in Java?
I tried this(test.sh), which fails
$ ./test.sh
d1FileToScriptMap
./test.sh: line 27: ${${myMap}["entities.csv"]}: bad substitution
line 27 is "scriptfile=${${myMap}["entities.csv"]}"
========= test.sh ===============================
#!/bin/bash
dataSources=("d1" "d2")
declare -A dataSrcToScriptAssociateArrayMap
dataSrcToScriptAssociateArrayMap=(
["d1"]=d1FileToScriptMap
["d2"]=d2FileToScriptMap
)
declare -A d1FileToScriptMap
declare -A d2FileToScriptMap
d1FileToScriptMap=(
["entities.csv"]="d1.sh"
)
d2FileToScriptMap=(
["entities.csv"]="d2.sh"
)
function main() {
myMap=${dataSrcToScriptAssociateArrayMap["d1"]}
echo ${myMap}
scriptfile=${${myMap}["entities.csv"]}
echo $scriptfile
}
main
====================================== | c********1 发帖数: 5269 | 2 Could you use python?
We can call linux command from python.
【在 o*****l 的大作中提到】 : 请教大侠们一个问题, 谢谢! : Is it possible to use bash to implement a data structure like : Map> in Java? : I tried this(test.sh), which fails : $ ./test.sh : d1FileToScriptMap : ./test.sh: line 27: ${${myMap}["entities.csv"]}: bad substitution : line 27 is "scriptfile=${${myMap}["entities.csv"]}" : ========= test.sh =============================== : #!/bin/bash
| n******7 发帖数: 12463 | |
|