Android Training Course (27)

Source: Internet
Author: User

<! -- @ Page {margin: 2 cm} P {margin-bottom: 0.21} -->

When I first read this code, I felt very strange. I didn't see any function that opened the file, nor did I close the file, so I could directly read and write the code. Can an object be opened automatically? It is impossible to call APIs in linux! Check the input command line repeatedly as follows:

Rgb2565-rle <xiyang. raw> initlogo. rle

From this command line, can you see some eyebrows? Why do we need to add things like braces to two files? Yes, these two parentheses are of special purpose. It is strange for programmers who have just switched from WINDOWS. Later I checked the shell call carefully. The details are as follows:

Standard Input
The standard input is the file descriptor 0. It is the command input. The default input is the keyboard, or file or other command output.

Standard output
The standard output is the file descriptor. 1. It is the command output. The default output is the screen or file.


Standard Error
The standard error is file descriptor 2. It is the output of the command error bit rate. The default value is the screen. It can also be a file.


Redirect operator description
> Write command output to a file or device (such as a printer) instead of a command prompt window or handle.


<READ command input from a file instead of a keyboard or handle.


> Add the command output to the end of the file without deleting the existing information in the file.

> & Write the output of one handle to the input of another handle.

<& Read the input from one handle and write it into another handle output.

| Read the output from one command and write it into the input of another command. It is also called an MPS queue.

Common File redirection commands

Shell code

Command> filename redirects the standard output to a new file

Command> filename redirects the standard output to a file (append)

Command 1> fielname redirects standard output to a file

Command> filename 2> & 1 redirects the standard output and standard error to a file.

Command 2> filename redirects a standard error to a file

Command 2> filename redirects the standard output to a file (append)

Command> filename 2> & 1 redirects the standard output and standard error to a file (append)

Command <filename> filename2 uses the command as the standard input in the filename file and the filename file as the standard output.

Command <filename: The command is input using the filename file as the standard.

Command <delimiter reads data from the standard input until the delimiter is encountered.

Command <& m uses the file descriptor m as the standard input

Command> & m redirects standard output to file descriptor m


From the detailed descriptions above, we can know the special location of this command line. The second parameter <xiyang. raw is used to redirect the xiyang. raw file to the standard input, that is, the data in the original format is opened as the input file.

The third parameter> initlogo. rle is opened as a standard output file.

 

Through this program, you can understand that the program writer is familiar with linux and has used it to the extreme, saving you the trouble of opening and closing files, which is extremely efficient.

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.