Special characters (\ t, \ r, \ n) in Linux and Windows)
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Special characters (\ t, \ r, \ n) in Linux and Windows -- Linux general technology-Linux programming and kernel information. For more information, see the following. Today, I wrote a Test Program (running in a Linux environment), in which some command strings must be pre-stored in a file, and then the test program reads these command strings from the file. In these command strings, fields are separated by the "\ t" separator. The end of each command string must end with "\ r \ n.
At the beginning, I simply put such a command string, such as "305 \ t00: 14: 22: 9C: 22: 9B \ t10.1.10.17 \ t \ r \ n "is saved to the file. However, when running the test program, the Command Format always prompts an error. I initially thought there was a problem with the function that reads the command string from the file, but after repeated experiments, I found that it was not a problem to read the file. By printing and displaying each character of the read string, I suddenly thought that the Delimiter is stored as a separate character in the file, rather than what they mean. ("\ T" is '\' and 't', rather than the TAB key)
Now that the problem is found, you can directly type the Tab key and the Enter key when saving the file. However, the return key in linux only represents "\ n", while the return key in windows represents "\ r \ n". Therefore, create the command string file in windows and upload it to linux. The problem is finally solved.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.