Linux bash,未找到命令

Linux bash,未找到命令,linux,bash,shell,Linux,Bash,Shell,我无法修复这个bash脚本中的错误,我真的不知道我做错了什么,非常感谢您的帮助 [centoslive@livecd ~]$ sh ListFich.sh test Synthese, Question 2 ListFich.sh: line 9: [-d: command not found Il n'y a aucun repertoire qui se nomme test ListFich.sh: line 15: [-f: command not found Il n'y a aucu

我无法修复这个bash脚本中的错误,我真的不知道我做错了什么,非常感谢您的帮助

[centoslive@livecd ~]$ sh ListFich.sh test
Synthese, Question 2
ListFich.sh: line 9: [-d: command not found
Il n'y a aucun repertoire qui se nomme test
ListFich.sh: line 15: [-f: command not found
Il n'y a aucun fichier qui se nomme test
[centoslive@livecd ~]$ 

[
之后添加空格,在
]
之前添加空格

[ -d $1 ]
 ^     ^

[
]
之前和之后需要空格。请参阅<代码>帮助[ < /代码>细节>

@ Joe:考虑使用<代码> [< /代码>和代码> >代码> BASH的更强大的构建,它提供了额外的运算符(=,),并且消除了引用字符串操作数的需要。[.愿意解释原因并提供一些参考链接吗?这会使这个答案更有用!@Kissaki看到前面的评论。@tarsailah我看到了那条评论。这主要是一个问答网站,而不是一个问答网站。答案应该尽可能完整,所以不是每个寻找答案的人都需要阅读所有的评论同样,你似乎在成功时退出1;按照惯例,这表示失败。
[ -d $1 ]
 ^     ^