Linux REDIRECT Command application and syntax

Source: Internet
Author: User

1. Control of standard input

Syntax: The command file sends the execution results of the command to the specified file.

For example:

Ls-l > List writes the results of the "ls-l" command to the file list.

Syntax: Command >! The file sends the execution result of the command to the specified file, overwriting if the file already exists.

For example:

LS-LG >! List to write the results of the "LS-LG" command to the file list.

Syntax: command >& file writes any information that is generated on the screen to the specified file when the command executes.

For example:

CC file1.c >& Error writes any information that is generated when the file1.c file is compiled into the file error.

Syntax: commands >> files Attach the results of a command execution to a specified file.

For example:

Ls-lag >> List attaches the results of the Execute "ls-lag" command to the file list.

Syntax: commands >>& files Attach any information that is generated on the screen to the specified file when the command executes.

For example:

CC FILE2.C >>& Error appends any information generated by the screen to the file error when compiling the file2.c file.

3. Command syntax

Command > FileName redirect standard output to a new file

Command >> filename REDIRECT standard output to a file (append)

Command 1 > Fielname redirect standard output to a file

Command > FileName 2>&1 redirects the standard output to a file with standard errors

Command 2 > FileName redirect standard errors to a file

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

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

Command filename2 the command command with the filename file as the standard input, filename2 file as the standard output

Command &m redirects standard output to the file descriptor m

Command

Related Article

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.