Shell Script syntax error near unexpected token `done’

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: