由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - bash to implement Map>
相关主题
为什么bash file执行的结果与直接在命令行执行的结果不一样can bash do this
请教bash命令请教一个sed命令 (转载)
虽然用不到了不过还是问一下吧...echo $VAR is not working in bash shell script ?
bash 中如何将命令的返回值存到变量中?求助问一个C Shell的sed用法。
Bash 里一个简单诡异的问题 (转载)问题
如何让bash不自动转换数字?ask a question about compile shared library using libtool (转载)
A simple Bash question about changing directoryhow to count a pattern in vi?
shell script和variable indexa sed question
相关话题的讨论汇总
话题: string话题: mymap话题: map
进入Linux版参与讨论
1 (共1页)
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
1 (共1页)
进入Linux版参与讨论
相关主题
a sed questionBash 里一个简单诡异的问题 (转载)
question about "stty"如何让bash不自动转换数字?
请问怎么把两个行数相等的文件合并起来?A simple Bash question about changing directory
shell scripting 问题shell script和variable index
为什么bash file执行的结果与直接在命令行执行的结果不一样can bash do this
请教bash命令请教一个sed命令 (转载)
虽然用不到了不过还是问一下吧...echo $VAR is not working in bash shell script ?
bash 中如何将命令的返回值存到变量中?求助问一个C Shell的sed用法。
相关话题的讨论汇总
话题: string话题: mymap话题: map