Tag Archives: syntax error near unexpected token `fi’

[Solved] Centos7 Execute Script Error: syntax error near unexpected token `fi’

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.