Get the App
SLTechnology News&Howtos  ›  Servers  › 

Standard output redirection 2 for linux

Shulou Source: shulou.com Published: 2022-06-02 12:31:50 10月03日 Update

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.

Tags: File standard output meaning device process error that is at the same time input run three examples background bottomless pit symbol empty Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Redmi Huawei Docker MariaDB