0

我正在尝试编写 .sh 但出现错误:
这是一个 minecraftserver 更新程序(仅供参考)

代码:

#!/bin/sh

# Deleting Old Files
if [ -e spigot1.jar]; then
  rm spigot1.jar

fi

# Renaming
if [ -e spigot.jar]; then
  echo Renaming File...
  mv spigot.jar spigot1.jar
  echo Done.
  echo
  else
  echo

fi

# Downloading
echo Downloading File...
wget http://ci.md-5.net/job/Spigot/lastBuild/artifact/Spigot-Server/target/spigot.jar
echo Done.

# Comparing Files
echo
echo Testing if the files are the same... 
if diff -a -w spigot.jar spigot1.jar >/dev/null ; then
  echo Done.
  echo
  echo -----------------------------------
  echo
  echo You already have the newest version!  
  echo
  echo -----------------------------------
else
  echo Done.
  echo
  echo -----------------------------------
  echo
  echo Updated to a newer version! 
  echo
  echo -----------------------------------

fi

if [ -e spigot1.jar]; then
  rm spigot1.jar

fi

sleep 10s

但它会弹出一条错误消息说:

test.sh: 4: [: missing ]
test.sh: 12: [: missing ]

有没有办法来解决这个问题?在解决这个问题之前我不能继续!在此先感谢
- derpasaurs

4

2 回答 2

6

你需要空间

if [ -e spigot1.jar ]; then

代替

if [ -e spigot1.jar]; then
于 2013-08-05T20:53:45.217 回答
0

如果上面的内容正是您所拥有的,那么问题是 和 之间缺少spigot.jar空间]

针对您的上述评论,此时您的代码是什么。通过上述更改,脚本对我来说运行良好。

于 2013-08-05T21:01:25.450 回答