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, the syntaxerrornearunexpectedtokendo error occurs in my for loop statement. be careful... 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 end of the line will be ^ m, which needs to be converted to "\ n" in linux/unix format. The conversion method is to convert the line break and 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 command, "represents the decision to reference parameters. the values in these parameters cannot be explained by shell, s indicates that the replaced content is followed by the replaced content. The Replaced content is null. we recommend that you use EditPlus or UltraEdit to use these text editing tools, you can select the type of the saved text encoding, for example, UNIX line breaks. 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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.