Shell script, when debugging, for loop that line of code, always errors syntax error near unexpected tokens do

Source: Internet
Author: User
This happens because the file line break you are working with is "\ r \ n" in DOS format.
You can use the Cat-v file name to see if the newline character is, and if it is, the end of the line will be ^m
"\ n" needs to be converted into Linux/unix format
The specific conversion method is to convert the newline character.
You can use the SED command to process a file with the following command:
Sed ' s/\r//' original files > converted Files
The parameters of the SED command "represents the decision reference parameter, does not allow the value in the argument to be interpreted by the shell, S represents replace/followed by the replaced content, followed by//represents empty after the replacement
It is recommended to use EditPlus or UltraEdit, using these text editing tools, when saving, you can choose to save the type of text encoding, such as the choice of UNIX format line break. I prefer the EditPlus join Lines function, which turns multiple rows of values into a logical line, making it easy to write into a shell script as a loop variable

Shell script, when debugging, for loop that line of code, always errors syntax error near unexpected tokens do (RPM)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.