time command uses std. error to give its result.
wn we type
$ time cat new\ file 2>/dev/null
its result shd not be printed. but its still being printed..
wts the prob ..??
eg .
[suhaas@localhost ~]$ time cat new\ file
#include<stdio.h>
int main()
{
printf("%d",macro);
}
real 0m0.003s
user 0m0.000s
sys 0m0.001s
[suhaas@localhost ~]$ time cat new\ file >/dev/null
real 0m0.008s
user 0m0.000s
sys 0m0.003s
but now wn im redirecting std. error to null still its result is being printed ..like
[suhaas@localhost ~]$ time cat new\ file 2>/dev/null
#include<stdio.h>
int main()
{
printf("%d",macro);
}
real 0m0.003s
user 0m0.000s
sys 0m0.003s
this last portion shdnt b there if its result is given by std error..but still its there. wts is the reason???
@ishkawa
time command as i have earlier said uses std. error to give its output so while im using 2>/dev/null it shouldnt give any out put ..
but thats not the case ,..
n i wanted a reson fr that..
Time does not use stderr for normal ouput. stderr is for error messages. stdout is for normal output. Time uses stdout to send output unless something goes wrong and it has to send error messages. Then it will send error messages to stderr.
If you use a command like
time 2> /dev/null
you will still see output sent to stdout but not output sent to sdterr.