Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Linux operating system redirect command

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report