我正在尝试通过 shell 测试节能器启动和关闭设置,我的字符串比较总是响应没有
这是我的代码
#!/bin/sh
pmset repeat shutdown MTWRFSU 19:00:00 wakeorpoweron MTWRF 07:00:00
test=`pmset -g sched`
schd="Repeating power events: wakepoweron at 7:00AM weekdays only shutdown at 7:00PM every day"
echo $schd;
echo $test;
if [ '$test' = '$schd' ]; then
echo "yes"
else
echo "no"
fi
我在这里做错了什么?
添加了这个,它按预期返回是
test2="Repeating power events: wakepoweron at 7:00AM weekdays only shutdown at 7:00PM every day"
schd2="Repeating power events: wakepoweron at 7:00AM weekdays only shutdown at 7:00PM every day"
if [ "$test2" = "$schd2" ]; then
echo "yes"
else
echo "no"
fi
我怀疑我的测试命令的输出中存在隐藏字符,因为其他一切似乎都是为了有某种方法来确认和消除它们,如果这实际上是问题?