Line breaks in different windows, UNIX, and Mac operating systems-profiling carriage returns \ r and linefeeds \ n

Source: Internet
Author: User

I. concept:

Line Break '\ N'AndCarriage Return '\ R'

(1) The linefeed is another line ---'\ N'
10 newline)

(2) The carriage return is to return to the beginning of a line ---'\ R'
13. Press enter (return)

Therefore, the carriage return character of the files we usually write is calledEnter a line break


II. Application:

(1) In Microsoft's MS-DOS and windows, use the "carriage return Cr ('\ R')" and "line feed LF (' \ n')" as line breaks; (2) In Windows, the end of each line is carriage return + line feed (CR + LF), that is, "\ r \ n ";
(3) In Unix systems, each line ends with a line break Cr, that is, "\ n". (4) in MAC systems, each line ends with a carriage return Cr or '\ R '.
Iii. Impact:(1) A direct consequence is that if a file in UNIX/MAC is opened in windows, all the text will become a line; (2) if files in windows are opened under UNIX/MAC, a ^ m symbol may be added at the end of each line. (3) If you use NotePad to view files stored in Linux, black spots will appear.
Iv. Mutual Conversion: In Linux, The unix2dos command converts the Linux file format to the Windows file format. The command dos2unix converts the Windows format to the Linux file format.
When FTP software is used to transfer files between different platforms, some FTP client programs automatically convert the line feed format in ASCII text transmission mode. the number of bytes transmitted may change. if you do not want to modify the original file via FTP, you can use bin mode (binary mode) to transfer text. A program runs on Windows to generate a text file in CR/LF line feed format, and runs on Linux to generate a text file in LF format line feed.

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.