我试图使用shell脚本将/etc/sysctl.conf
中的实际值与推荐值进行比较。这两个值都是相同的,但不是执行if
,而是执行else
语句。
shmmnireq=4096
shmmni=$(grep "shmmni" /etc/sysctl.conf | cut -d " " -f3)
echo $shmmnireq
echo $shmmni
if [[ $shmmnireq == $shmmni ]];then
echo "shmmni is configured"
else
echo "shmmni is not configured"
fi
输出:
4096
4096
shmmni is not configured
最佳答案
试试这个-
#!/bin/bash
shmmnireq=4096
shmmni=$(grep "shmmni" /etc/sysctl.conf | cut -d " " -f3)
echo $shmmnireq
echo $shmmni
if [ "$shmmnireq" -eq "$shmmni" ];then
echo "shmmni is configured"
else
echo "shmmni is not configured"
fi
关于linux - 如何修复此脚本以获得正确的输出?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56880333/