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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.