【发布时间】:2014-02-22 19:15:24
【问题描述】:
我已尽我所能得到结果,但我做不到。我请求你以正确的方式指导我。
Bellow 是我的 bash 脚本,它实际上是一个 init.d 脚本。
#!/bin/bash
LOG_LEVEL="info debug_rpc warn test critical debug_sql error debug debug_rpc_answer notset"
CHECK_LOG_LEVEL=$2
logcheck() {
if [ ! -z $CHECK_LOG_LEVEL ]; then
if [ "$(grep -o "$LOG_LEVEL")" == "$CHECK_LOG_LEVEL" ]; then
echo "Starting the daemon with log_level"
else
echo "Check if the log-level argument name is correct!"
exit 1
fi
else
echo "Starting the daemon"
fi
}
case "${1}" in
start)
logcheck
;;
esac
exit 0
我希望 grep 匹配确切的单词。因为 debug_rpc、debug_rpc_answer、debug_sql
如果您的用户通过运行以下脚本而出现拼写错误: sudo /etc/init.d/myscript.sh start debug_rp
需要显示 {echo "Check if the log-level argument name is correct!"}
我正在尝试将存储在变量 $CHECK_LOG_LEVE 中的确切用户参数与内容 $LOG_LEVEL 匹配
对此的任何指导或解决方法..
谢谢。
【问题讨论】: