例如,我们如何检查数组中是否存在字符串索引
declare -A SArray
SArray[a]="a"
SArray[b]="b"
read index
现在在索引上,我想检查 SArray 中是否存在索引
最佳答案
#!/bin/bash
declare -A SArray
SArray[a]="a"
SArray[b]="b"
read index
if test "${SArray["$index"]+isset}"; then
echo "index $index exists for SArray"
else
echo "no index $index for SArray"
fi
关于linux - 检查字符串索引是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30866817/