Map
#!/usr/bin/env bash
declare -A mymap=(["sunjun"]="a" ["jason"]="b" ["lee"]="c")
#输出所有key值
echo ${!mymap[@]}
#输出所有value值
echo ${mymap[@]}
#查找和删除
findkey=$1
value=$2
# 查找
echo ${mymap[$findkey]}
if [ ! -n "${mymap[$findkey]}" ]
then
echo "not find value"
mymap[$findkey]=$value
else
echo "find value"
unset mymap[$findkey]
fi
echo ${!mymap[@]}
echo ${mymap[@]}
awk
根据jar名称,查询pid,kill进程
ps -ef|grep ${jar_name}-exec | grep -v "grep"| awk '{print $2}' |xargs kill -9
if
数组
#!/usr/bin/env bash
function showArr(){
arr=$1
for i in ${arr[*]}; do
echo $i
done
}
regions=("GZ" "SH" "BJ")
showArr "${regions[*]}"