shell脚本syntax error near unexpected token `done'

1, modify the file type

Execute:
vi finddir.sh
enter
: set ff
if fileformat = dos, amended as UNIX:
: set ff = UNIX
perform the save command:
: WQ

2, delete hidden characters

Command vi -b open your SHELL script file, you will. Found that each line of the script last more than a ^ M
because MS-DOS and Windows are carriage return + line for newline, so look at the code in Windows using VC written in Linux using Vim, after the end of the line "^ M" symbol It indicates the character.

In Vim using alternative feature can be "^ M" kill all, alternative type the following command line:
. 1) the setup.sh VI -b
2) on the command line editor <is: Press ESC then shift +: colon> Input:% s / ^ M // g
Note: the above command line "M" symbol is not "" coupled with "M", but by "Ctrl + v", "Ctrl + M" generated keys.
After so replaced, saving can be performed.

Reference: https://blog.csdn.net/Michael177/article/details/101618068

Guess you like

Origin www.cnblogs.com/chen-chen-chen/p/12234003.html