技术解析
# cat compare.sh
#!/bin/bash
status=$(/tmp/vpn/vpn1.exp | grep '10.31.90.101'|awk '{print $NF}'|uniq)
echo "$status"
if [[ "$status" == "A" ]];then
echo 'A'
else
echo 'not A'
fi
# /tmp/vpn/vpn1.exp | grep '10.31.90.101'|awk '{print $NF}'|uniq
A
# ./compare.sh
A
not A
为什么 /tmp/vpn/vpn1.exp | grep '10.31.90.101'|awk '{print $NF}'|uniq 输出是个 A , 但在 if [[ "$status" == "A" ]]比较确失败了?代码直接执行了 else 部分