我正在尝试在我的密码上输入“帮助”命令
read -p ">> " cmd
if ( $cmd == "help" )
then
echo
echo "help - this page"
else
echo
echo "error command"
fi
当我写帮助时:
>> help
help: help [-dms] [pattern ...]
Display information about builtin commands.
Displays brief summaries of builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise the list of help topics is printed.
Options:
-d output short description for each topic
-m display usage in pseudo-manpage format
-s output only a short usage synopsis for each topic matching
PATTERN
Arguments:
PATTERN Pattern specifying a help topic
Exit Status:
Returns success unless PATTERN is not found or an invalid option is given.
help - show this page
我只希望看到BASH的“帮助-显示此页面”而不是“帮助”
答案 0 :(得分:2)
if
语句应如下所示(使用双括号):
if [[ $cmd = "help" ]]
这是脚本的主要问题。