bash associative array key string with colon is giving error

橙三吉。 提交于 2019-12-02 12:33:40

That's not an associative array. You need to use declare -A, not declare -a.

$ declare -A SrcDstMap
$ SrcDstMap["9c:4e:20:73:e2:72"]="ff:ff:ff:ff:ff:ff"
$ declare -p SrcDstMap
declare -A SrcDstMap=([9c:4e:20:73:e2:72]="ff:ff:ff:ff:ff:ff" )

declare -a creates a numerically indexed array, so the shell is trying to parse your index as a number.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!