Syntax error: end of file unexpected (expecting “then”)

前端 未结 3 1769
长发绾君心
长发绾君心 2020-12-16 16:00

I am making this code for a minecraft server plugin updater I am a new shell scripter so I don\'t know alot...
when I run this code I get a error:

#!/bin         


        
相关标签:
3条回答
  • 2020-12-16 16:15

    It's because of file formatting. I faced the same problem. Just create another file with (.sh) extensions using gedit. Then paste the code into the new document. Hope this will resolve the issue.

    gedit file-name.sh

    0 讨论(0)
  • 2020-12-16 16:18

    I have met the same problem. And the problem is the format of the file is "dos", but in linux shell requires "unix", so I install the "dos2unix"

    $ sudo apt-get install dos2unix
    

    or if you use emacs, you can do this:

    C-x RET f unix
    

    Good luck :)

    0 讨论(0)
  • 2020-12-16 16:29
    1. The Unix directory separator is forward slash not backslash.
    2. Does your editor on windows have an option to save files in "Unix" file format? The shell is seeing the word then^M with a carriage return on the end. If you don't have dos2unix then try running this command: sed -i 's/\r$//' filename
    0 讨论(0)
提交回复
热议问题