When the script written on the window computer is executed on Linux and always reports an error, as shown below
syntax error near unexpected token `fi'
Solution:
Open the file with vim and enter it in command line mode
:set ff If it shows fileformat=dos Now set our code mode with the command: set ff=unix Execute: wq! Check again to see that the code is programmed for unix
Via cat – V * * SH check that the code is normal.
In this way, there will be no errors when executing the code again.
Similar Posts:
- [Solved] “/bin/bash^M: bad interpreter: No such file or directory”
- Shell Error: bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory [How to Solve]
- syntax error near unexpected token `do [How to Solve]
- shell :syntax error: unexpected end of file
- [Solved] Python Error: /usr/bin/python^M: bad interpreter: No such file or directory
- When Linux runs SHELL file, $’\ R’: command not found appears
- Conversion to MySQL shell script execution error $’\ R’: command not found
- Solve the problem of shell script “syntax error near unexpected token ` fi ‘”.
- shell :syntax error: unexpected end of file
- How to Solve Error: set ff? /bin/bash^M: bad interpreter: No such file or directory