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

Shell redirection

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

There are three files opened by the system under Liunx, namely, standard input, dimension output and standard error output. The user's shell sets the keyboard as the default standard input, and the default standard input and standard error output as the screen. That is, the user enters commands from the keyboard and then inputs the results and error messages to the screen

The so-called redirection is not applicable to the system default dimension input / input, but redirection, so the redirection is divided into input redirection, input redirection and error output redirection. To achieve redirection, you need to know the redirection operator, and shell determines the redirection operation based on the redirection operator.

(1) enter the redirection operators''and' > >'

Output redirection does not output the output of the command on the screen, but to a specified file.

Output redirection is used a lot under Linux. For example, if the output of a command is so long that a screen cannot be displayed, you can specify the output of the command to a file, and then use the more command to view the file to get the complete information of the output of the command.

This command outputs all the system running process information output from ps-ef to the ps.txt file instead of to the screen. You can use the more command to view the information processes running by the system in the ps.txt file.

Note: if the file specified after'> 'does not exist, shell will automatically rebuild one; if the file exists, the original contents of the file will be overwritten; if you do not want to overwrite the existing file, you can use the' > > 'operator.

This command appends all file information in the / etc directory and its subdirectories to the end of the / root/install.log file. The original contents of the / root/install.log file still exist.

(3) error redirection operator'2 >'2 > >'

Error redirection is the same as marking output redirection. Redirection of error output

Where tar is the package name command, you can see the decompression process of tar on the screen. If 'text.tar.gz' is a corrupted compressed package, the error message will be output to the errot.txt file.

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

Network Security

Wechat

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

12
Report