html tool

2017年6月14日星期三

shell定义字典

参考:http://www.firefoxbug.com/index.php/archives/2369/


  1 #!/bin/bash
  2 #add:http://www.firefoxbug.com/index.php/archives/2369/
  3 echo "shell定义字典"
  4 #必须先声明                                                                                                                                       
  5 declare -A dic
  6 dic=([110_2]="172.16.110.2 275734"\ 
  7      [110_3]="172.16.110.3 2757334"\ 
  8      [110_4]="value3")
  9 #key="110_2" #$1
 10 key=$1    
 11 #打印指定key的value
 12 echo ${dic["${key}"]}
 13 #打印所有key值
 14 echo ${!dic[*]}
 15 #打印所有value
 16 echo ${dic[*]}

没有评论:

发表评论