Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the Linux operating system redirect command

Shulou Source: shulou.com Published: 2022-06-01 06:34:54 10月03日 Update

This article mainly introduces how to use the Linux operating system redirect command, the article introduces in great detail, has a certain reference value, interested friends must read it!

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 result of the "ls-l" command to the file list.

Syntax: command >! The file sends the execution result of the command to the specified file, and if the file already exists, it is overwritten.

For example:

Ls-lg >! List overwrites the results of the "ls-lg" command to the file list.

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

For example:

Cc file1.c > & error writes any information generated when compiling the file1.c file to the file error.

Syntax: command > > file appends the result of command execution to the specified file.

For example:

Ls-lag > > list appends the result of executing the "ls-lag" command to the file list.

Syntax: command > > & File appends any information generated on the screen when the command is executed to the specified file.

For example:

Cc file2.c > > & error appends any information generated by the screen when compiling the file2.c file to the file error.

3. Command syntax

Command > filename redirects standard output to a new file

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

Command 1 > fielname redirects standard output to a file

Command > filename 2 > & 1 redirect standard output and standard error to a file together

Command 2 > filename redirects standard error to a file

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

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

Command filename2 uses filename files as standard input and filename2 files as standard output for command commands.

Command & m redirects standard output to the file descriptor m

The above is all the contents of this article entitled "how to use Linux operating system Redirect commands". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Files commands standards output results syntax information attachments screens errors operating systems systems content articles compilations inputs values interests boys buddies Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Apple Shulou Technology NVidia Huawei