A shell script error often occurs when writing a script: Write it in windows and copy it to execute it. However, an error is reported when you test it, the error is amazing. for example, my for loop statement encountered a syntax error near unexpected token do error. I carefully read the shell script I wrote several times and found that there was no error, the last possible cause is that the line break www.2cto.com is caused by the dos format "\ r \ n". You can use the cat-v file name to check whether the line break is true, if this is the preceding, the line ends with ^ m and needs to be converted to "\ n" in linux/unix format. The specific conversion method is to convert the line break. You can use the sed command to process the file, the command is as follows: sed's/\ r // G' original File> in the parameters of the converted file www.2cto.com sed ", it indicates that the reference parameter is determined. The value of this parameter cannot be explained by shell, s indicates replacement. The replacement is followed by replacement. The content, followed by // indicates that the replaced content is empty. EditPlus or UltraEdit is recommended. When using these text editing tools, you can select the type of the saved text encoding when saving the content, for example, select a UNIX line break. I prefer the join lines function of EditPlus to convert the values of multiple rows into a logical row, which is easy to write to shell scripts as cyclic variables.