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

Standard output redirection 2 for linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

There are three standard IO,stdin,stdout,stderr in Linux, and the corresponding file descriptor is 0Person1, Person2.

2 > & 1 means to redirect standard error to standard input.

Why do you need a & symbol because & it must be followed by a file descriptor

Otherwise, 2 > 1 means to redirect standard error to a file with a file name of 1.

1 > / dev/null means to redirect standard output to a / dev/null device file, and null represents an empty device file, which can be understood as null is a bottomless pit.

So 2 > & 11 > / dev/null, this sentence redirects standard error to standard input while standard output is redirected to a / dev/null device file, that is, stdin/stdout is redirected to a / dev/null device file.

Examples are as follows:

Xxx_process 2 > & 1 1 > / dev/null &

Start a process named xxx_process to redirect the output log it is running to the / dev/null file

That is, in this process, printf cannot print log, and the process runs in the background.

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