I have this code that produces an error, and it works to supress the STDOUT but it doesnt store the STDERR in the variable ERROR.
ERROR = $(memtester 900 1 > /dev/null)
You can capture it like this:
error=$(memtester 900 1 2>&1 >/dev/null)
order of redirection operators is important here.
2>&1
- redirects stderr to stdout>/dev/null
- redirects stdout to /dev/null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With