Line feed conversion-general Linux technology-Linux technology and application information. For more information, see the following section. From windows to linux, some previously written script programs need to convert line breaks before they can run normally.
The conversion method is actually very simple:
Sed-e's/\ r // G' old_file> new_file
You can.
In windows, the line break is \ r \ n, and in linux/unix, It is \ n. \ R = 0x0d indicates the carriage return, \ n = 0x0a indicates the line feed.
The early computer output device was not a display, but a telex typewriter with a structure similar to a common typewriter. There is a print head typing on paper, and a motor controls the paper in and out. When the print header reaches the end of a row, two actions are required to reach the first row of the next row: first, run the carriage return action to move the print header to the beginning of the row, and then wrap the line, the motor moves the paper one line up, so that the print head is at the beginning of the next line, you can continue printing. The control characters corresponding to carriage return and line feed are \ r and \ n, which are the origins of the line break \ r \ n in windows. Later, due to frequent continuous execution, the two control characters in the printer were simplified to a control character, which is the origin of the line break \ n in linux/unix.
In the past, the line break for Apple was \ r. Later, Apple's operating system mac OS x used freebsd and mach kernels, both of which were unix operating systems, therefore, the linefeed in mac OS x may be \ n (speculation ).
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