I have a Bash script:
#!/bin/bash
echo this should be visible only in the stderr output but it is not 1>&2
exit 0
Also, I have a custom app that starts this script. The app captures both - stdout and stderr. The stdout is empty and the stderr contains the text provided. So far, so good. But when I start the script from the console (physical terminal):
./my_script.sh
I expect it to not print anything on the display, but it prints.
I tried various combinations of redirecting, e.g., >&2
, >/dev/stderr
, etc. but results are the same. I also tried to redirect stdout to null 1>&2 >/dev/null
, but obviously it also sends my text to the null.
Where is this configured? How can I make my terminal to not display stderr?
script 2>/dev/null
works../script
and it automatically disconnects stderr from the terminal?exec 2>/dev/null
.exec 2>/dev/null
in the very first line of your bash script. In this way you can just execute./script