Reset to default
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
./script 2>&1 1>/dev/null | ./other-script
The order here is important. Let’s assume stdin (fd 0), stdout (fd 1) and stderr (fd 2) are all connected to a tty initially, so
0: /dev/tty, 1: /dev/tty, 2: /dev/tty
The first thing that gets set up is the pipe. other-script’s stdin gets connected to the pipe, and script’s stdout gets connected to the pipe, so script’s file descriptors so far look like:
0: /dev/tty, 1: pipe, 2: /dev/tty
Next, the redirections occur, from left to right.
2>&1 makes fd 2 go wherever fd 1 is currently going, which is the pipe.
0: /dev/tty, 1: pipe, 2: pipe
1>/dev/null redirects fd1 to
0: /dev/tty, 1: /dev/null, 2: pipe
End result, script’s stdout is silenced, and its stderr is sent through the pipe, which ends up in other-script’s stdin.
Also note that
1>/dev/null is synonymous to, but more explicit than
How about this:
./script 3>&1 1>/dev/null 2>&3 | ./other-script
The idea is to “backup” stdout descriptor, close the original stdout and then redirect strerr to saved stdout.
Its much similar to the solution provided by geirha, but its more explicit (bash coding can easily become very obscured).
Well, that’s because you can’t. STDOUT and STDERR are just two files, represented by file descriptors, which are just integers, specifically 1 and 2.
What you’re asking is to set descriptor 2 to
/dev/null, then set descriptor 3 to the same file descriptor 2 and have that output go somewhere else.