sh 中的小安装脚本
我在sh中编写了一个小安装程序。
代码:
#!/bin/sh
echo $ 1
if [ "$1" ! = "install"];
then
echo "Why not install?
else
echo "Installing ..."
fi
并引发错误:
安装
[:10:丢失]
安装...
编辑:回滚问题答案的操作。
I programmed a small installation program in sh.
code:
#!/bin/sh
echo $ 1
if [ "$1" ! = "install"];
then
echo "Why not install?
else
echo "Installing ..."
fi
And throws an error:
install
[: 10: missing ]
Installing ...
EDIT: Rolled back incoperation of answers into question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应该是
should be
这里有多个问题
第一行应该以
In shell script
if
开头,并且[
实际上是一个程序(它是test
test 程序),而不是语法的一部分,因此您需要确保将其隔开,以便 if 和 '[' 以及任何内容都被分隔开 - 即注意空格每个元素之间——没有空格就无法工作。
您还需要终止带引号的字符串,因此不要
确保引号位于行尾
Multiple problems here
The first line should start with
In shell script
if
takes a program, and[
is actually a program (it is an alias for thetest
program), and not a part of the syntax, so you need to make sure you space it out so that if and the '[' and anything out is separated out -- i.e.Note the spaces between each and every element -- it will not work without spaces.
You also need to terminate your quoted strings, so instead of
Make sure you have the quote at the end of line