Unix size 1byte Files--line breaks (EOL)

Source: Internet
Author: User
Tags eol

A colleague with Tcl and Ksh wrote a program, use for an operation, if there is error to write the error message to a file, write method is 2> $stderr, and then judge the size of the file, if greater than 0, then think that there is a mistake, error.

It is strange that the program has not been successfully executed and has been an error. Colleagues tracked his code line by row, and found that the file $stderr was just created with a size of 0, but after a while he will become 1byte. However, when you open the view, the contents of the file are empty. Later, vi in accordance with the 16 into the system opened (:%!XXD), found 0a.

0X0A is the default line terminator (EOL) under UNIX, which is available in every row. We experimented with using print to create a file under Unix:

Print $test > Test

Where $test is an undefined variable, a file of size 1byte is generated. Open the file, you can also find the existence of 0a.

However, if the C language to write a file operation function, but can get a size of 0 and opened after the 0a file. It's strange ...

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.