Solve the error of executing script under Linux: unexpected EOF while looking for matching ``' and syntax error: unexpected end of file

  • Problem Description

   When executing the shell script, the following error occurred:
 
Insert picture description here

  • Troubleshoot errors

Error 1: unexpected EOF while looking for matching,
Translation: Unexpected EOF (end of file) when looking for a match ``,
 
error 2: syntax error: unexpected end of file
Translation: syntax error: unexpected end of file

  • Solve the problem

Looking at the error on line 10, when matching `` (backquote), an unexpected end of file occurred. Then I went back and looked at the code on line 10 and found that an extra `(backquote) was written at the end of the line, which would cause the command on line 10 to not be executed, and then an error was reported.
Let me look at the error report on line 11. My script only has 10 lines. Why is there an error on line 11? Because there is an extra backquote, the system thinks that there is content behind my script, but there is no content, and then it reports an error that the file ends unexpectedly.

  • to sum up

When I finished writing the script, I accidentally pressed the backquote when I saved and exited. However, when the error occurred, the backquote was too small to be seen. Don't be afraid if you make a mistake, this is the time to improve yourself.

Guess you like

Origin blog.csdn.net/weixin_46818279/article/details/108001514