The ^ m newline character in the file-Linux general technology-Linux programming and kernel information. The following is a detailed description. The script edited in windows is directly used in linux. A syntax error: unexpected end of file error occurs.
I never understood it before, but later I understood it Because windows and unix have different line breaks.
Cat-v file
Check whether the file contains a line break character in the ^ M format.
Cat file | col-B> newfile: delete all ^ M.
Or dos2unix filename
Or in the editor
Vim: s/\ r // g
Vi: s/ctrl + v ctrl + m // g
No error is reported when the script is executed.
In addition, it is a good habit to use sh-n file. sh to check for syntax errors before executing the script.
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