Syntax Error: unexpected end of File or /bin/bash^M: bad Interpreter: No such file or directory
For example:
[root@sjk3 ~]# sh percona-xtradb-cluster-install. Sh
percona-xtradb-cluster-install. Sh: line 25: syntax error: unexpected end of file
or
Sh
-bash:./ percona-xtradb-cluster-install:./ percona-xtradb-cluster.sh: /bin/bash^M: bad interpreter: No such file or directory
When executing shell scripts, such errors are prompted mainly because shell script files are in DOS format, where each line ends with \r\n and Unix format files end with \n.
Several ways to view a script file in DOS or Unix format:
Method 1
Vi filename or Vim filename opens the file, in DOS format, with a prompt at the bottom [DOS]
If it is in Unix format, there is no prompt at the bottom
Method 2
Vi filename or Vim filename opens the file and executes :set FF, enter. If the file is in DOS format, it will be displayed as FileFormat = DOS; if it is in Unix format, it will be displayed as FileFormat = Unix as shown in the figure below:
, enter
or
Methods 3
Cat -A filename can tell from the display that the DOS file ends with A line to the ^M$and the Unix file ends with A line of $
Solutions:
Method 1
Vi filename or Vim filename opens the file, executes: set FF = Unix setting the file as Unix, then executes: WQ, saving to Unix format.
Method 2
Use the sed command sed – I “s/\r//” filename or SED – I “s/^M//” filename to directly replace the terminators in Unix format.
(sed – I “s/\r//” filename is recommended, as sed – I “s/^M//” filename may become invalid)
Read More:
- Solve the problem of syntax error: unexpected end of file or syntax error near unexpected token ` fi ‘error
- The Linux terminal appears bash: setup.bash : no such file or directory, and. Bashrc file
- Linux has no way to solve bash. / that file or directory
- bash: /opt/ros/kinetic/ setup.bash : there is no file or directory
- Remove M Characters “Control M” or “^M” or “CTRL M” Characters in a UNIX file
- Ubuntu 64 prompts bash: no such file or directory file exists
- When installing ROS: bash / opt / ROS / kinetic/ setup.bash : there is no file or directory
- Solve the problem of “bash. / don’t have that file or directory” in Ubuntu 64 bit
- Syntax error: unexpected end of file problem [two solutions]
- How to solve the problem of “unable to open include file:” graphics. H “: no such file or directory”
- Syntax Error: Error: ENOENT: no such file or directory, scandir ‘D:
- Cannot open include file: ‘io.h‘: No such file or directory
- Syntax error near unexpected token ‘$’Do is reported when running bash file
- VS2010 compiler can’t open include file: “GL / glaux. H”: no such file or directory
- In VS2010, the compiler cannot open the file “GL / glaux. H”: no such file or directory
- Importerror of [docker] error: libGL.so .1: cannot open shared object file: No such file or directory
- #During OpenGL development, fatal error C1083: can’t open include file: “GL / glut. H”: no such file or directory
- Solution of header file StdAfx. H “no such file or directory” in Visual Studio
- When Python Django creates a database, can’t open file ‘ manage.py ‘: [Errno 2] No such file or directory
- Solution to error opening trace file: no such file or directory (2) in Android