1. Modify the file type
Vi finddir.sh enter: set ff If fileformat= DOS, change to Unix: : set FF = Unix execute save command: : WQ
2. Delete hidden characters
Open your SHELL script file with the command VI-b, and you will. It is found that there is an extra ^M at the end of each line of the script because MS-DOS and Windows are return + line feed to represent line feed. Therefore, Vim is used in Linux to view the code written in Windows with VC. The “^M” symbol at the end of the line represents the character.
To eliminate “^M” in Vim with the substitution function, type the following substitution command line: 1) vi-b setup.sh2) on the command edit line
< That is: press ESC and shift: colon >
Note: the “M” character on the command line above is not “” and” M “, but is generated by “Ctrl V” and “Ctrl M”. After this substitution, the save is ready to be executed.
Read More:
- Running shell script reports an error: “syntax error near unexpected token solution ‘”
- [Solved] Linux shell Script Error: syntax error near unexpected token `do
- Ubuntu shell Script syntax error near unexpected token `$‘{\r‘‘
- [Solved] Shell error: syntax error: unexpected end of file
- [Solved] bash: /etc/vimrc: line 15: syntax error near unexpected token `“autocmd“‘
- Windows writes shell script and executes shell error [Solved]
- [Solved] shell Error: Syntax error: “(“ unexpected (expecting “}“)
- [Solved] Bash: Syntax error: redirection unexpected
- [Solved] Linux executes SQL script Error: Syntax error
- [Solved] sbatch: error: Batch script contains DOS line breaks (\r\n)
- [Solved] yum command Error: “except keyboardinterrupt, e: syntax error: invalid syntax”“
- Shell: How to Get System Current Tme and Format it
- subprocess installed post-installation script returned error exit status 1
- Login Error: token failed, reason: getaddrinfo EAI_AGAIN ks-apiserver (kubesphere is Installed)
- Prompt “entering emergency mode. Exit the shell to continue” if the Linux operating system does not start normally
- npm ERR! Failed at the [email protected] install script.
- [Solved] Linux SSH Login Terminal Error: shell request failed on channel 0
- MAC Adb Shell Error: -bash: adb: command not found, adb
- [Solved] Ubuntu Server 18.4 System /etc/sudoers: syntax error near line 32
- Centos7 Start Error: Entering emergency mode.Exit the shell to continue