shell中的map使用
来源:互联网 发布:万云网络 编辑:程序博客网 时间:2024/06/07 23:42
[root@linkea-dev-srv1 ~]# declare -A abc-bash: declare: -A: invalid optiondeclare: usage: declare [-afFirtx] [-p] [name[=value] ...]
bash 的版本必须 >= 4.1.2,升级bash:
# wget http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
# tar -zxvf bash-4.2.tar.gz
# cd bash-4.2
# ./configure
# make && make install
# mv /bin/bash /bin/bash.old
# ln -s /usr/local/bin/bash /bin/bash
# 重新登录
# sh -version
# GNU bash, 版本 4.2.0(2)-release (x86_64-unknown-linux-gnu)
- shell中map的定义与使用
declare -A 变量名#切记使用大写的A,不是小写的a
[root@www ~]# declare -A map=(["sunjun"]="a" ["jason"]="b" ["lee"]="c") #定义时初始化一些值[root@www ~]# echo ${map[@]} #输出所有valuesa c b[root@www ~]# echo ${!map[@]}#输出所有keyssunjun lee jason
[root@www ~]# map["hello"]=123#向map中添加一个key=value[root@www ~]# echo ${map[@]}a c b 123[root@www ~]# echo ${!map[@]}sunjun lee jason hello[root@www ~]#
- shell中的数组
[root@www ~]# declare -a array=("aa" "bb" "cc")#定义一个数组[root@www ~]# echo ${array[@]}#输出所有元素的值aa bb cc[root@www ~]# echo ${!array[@]}#输出所有元素的索引0 1 2
[root@www ~]# array[100]="hello"#指定索引添加一个元素[root@www ~]# echo ${array[@]}aa bb cc hello[root@www ~]# echo ${!array[@]}0 1 2 100[root@www ~]#
- shell中的map使用
- shell中的map使用
- shell中的map实现
- STL中的map使用
- js中的map使用
- shell 中的EOF使用
- shell 中的循环使用
- shell中的${},##, %% , :- ,:+, ? 的使用
- shell中的${},##, %% , :- ,:+, ? 的使用
- shell中的${},##, %% , :- ,:+, ? 的使用
- shell中的${},##, %% , :- ,:+, ? 的使用
- shell中map的使用和遍历
- shell中map的是使用
- Map/Reduce中的Partiotioner使用
- Scala中的Map使用例子
- python 3中的map使用
- Golang中的map的使用
- shell map
- 智能家居
- 根目录,子目录 and 当前目录的区别及解析
- 信息安全与BI
- 杭州奢侈品回收哪儿好
- 微信公众平台开发教程第20篇-新手解惑40则
- shell中的map使用
- cocos2d-x 安卓环境配置 -转
- 1.1 自话粒子群
- RakNet学习(49) -- Router2
- android之退出应用程序
- Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined
- 《长尾经济》 笔记
- cocos2d-x-2.2 window下配置笔记(ADT+android-ndk-r9b) 无cygwin。非常全面!!!!
- RakNet学习(50) -- SQLite3LoggerPlugin设置