sh 校验用户输入的密码是否正确;判断变量是否等于0
#!/bin/bash
# 校验用户输入的密码是否正确
read -p '请输入密码:' PASSWORD
# 校验密码
echo "${PASSWORD}" | sudo -S apt policy openssh-server
res=$?
#when the condition is true
if [ "$res" -eq 0 ]; # eq等于
then
echo "密码正确"
else
echo "密码错误"
fi
#!/bin/bash
# 校验用户输入的密码是否正确
read -p '请输入密码:' PASSWORD
# 校验密码
echo "${PASSWORD}" | sudo -S apt policy openssh-server
res=$?
#when the condition is true
if [ "$res" -eq 0 ]; # eq等于
then
echo "密码正确"
else
echo "密码错误"
fi