Tagged Questions
3
votes
2answers
106 views
Copy stdout and stderr to a log file and leave them on the console within the script itself
Using bash, how do I copy stderr and stdout to a log file and also leave them displayed on the console?
I would like to do this within the script itself using an exec.
I tried with
exec ...
2
votes
1answer
52 views
Why is it possible to refer to a closed stderr under bash?
I'd like to know why bash doesn't display an error message when we refer to a closed stderr. When it comes to other file descriptors, they have to be opened if we want to, for example, duplicate them. ...
2
votes
1answer
73 views
Stderr of piped shell scripts isn't always displayed
I piped my own shell scripts for some testing and accidentally noticed something strange. Namely, the stderr of those piped processes isn't always displayed on the screen.
I simplified the scripts ...
7
votes
2answers
491 views
Does `Segmentation fault` message come under STDERR?
I ran an executable in bash
./code > log
It shows occasional error messages on terminal whereas all printf statements go into log file. I re-run it like below
./code >& log
Now, the ...
2
votes
2answers
352 views
How to redirect error to a file?
I have this simple script which redirects the output and append it to a file.
filename="/home/ronnie/tmp/hello"
date=$(date)
echo "$date" >> $filename
Now, lets suppose I change date=$(date) ...
4
votes
2answers
134 views
Redirect stderr of the double-parentheses construct
I'd like to be able to redirect the stderr of a double-parentheses construct.
For example:
a=$(($var/$var2))
would output some error messages if $var2 = 0, I do not want the user to see this.
I ...