Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have redirected stdout and stderr, why do I still get some output?

Tags:

bash

shell

I did something like the following in a bash terminal

( some_command ) >/dev/null 2>/dev/null

Yet I still got something printed. Here some_command runs a command-line program private to my organization. How did the sub-shell manage to print something to the console while I redirected both STDOUT and STDERR?

like image 990
user716468 Avatar asked Jan 30 '26 19:01

user716468


1 Answers

One possibility is that the program is particularly rude and is printing to the controlling terminal directly, which would circumvent all redirecting.

For example:

$ ( echo "can't touch this" > /dev/tty ) >/dev/null 2>/dev/null
can't touch this

(/dev/tty refers to the current process's controlling terminal.)

like image 119
Eevee Avatar answered Feb 01 '26 14:02

Eevee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!