bash的输出指令未发现 [英] bash output command not found

查看:136
本文介绍了bash的输出指令未发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林面临以下的问题我已经创建提到的条件,但是当我选择y代表是一切正常,但是当我选择n不我招人烦的错误输出:
输出:
你是否同意是(Y)否(N)
ñ
./myscript:[N:命令未找到

Im facing following problem I have created mentioned condition, but when I choose y for yes everything is ok, but when I choose n for not I get annoying error output: output : Do you agree yes (y) or not (n) n ./myscript: [n: command not found

的MyScript是我的脚本的名称
code位置:

myscript is the name of my script Code here:

echo  "Do you agree yes (y) or not (n)"
read  answer
if ( [ "$answer" =  'y' ]  ||  ["$answer" = 'Y' ]);
then

echo  -e  "  output for y"
done
else
echo -e "  output for n "
exit 1;

不知道如何才能摆脱输出和解决问题?
谢谢

Any idea how can I get rid of the output and fix the problem ? thanks

推荐答案

您错过了在空间:

["$answer" = 'Y' ]

更改为:

[ "$answer" = 'Y' ]

有,可以在脚本中的其他错误。在这里,你有工作code:

There are also other mistakes in the script. Here you have working code:

echo  "Do you agree yes (y) or not (n)"
read  answer
if ( [[ "$answer" =  'y' ]] || [[ "$answer" = 'Y' ]]);
then
 echo -e "  output for y"
else
 echo -e "  output for n"
exit 1
fi

这篇关于bash的输出指令未发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆