To colucix
I know what is result of this
Code:
$ cat file xxx 2>stderr 1>stderr
$ cat stderr
cat: xxx: No such file or directory
first I do
Code:
[root@localhost ~]# cat file xxx
filecontent
cat: xxx: No such file or directory
[root@localhost ~]#
second I do
Code:
[root@localhost ~]# cat xxx file
cat: xxx: No such file or directory
filecontent
[root@localhost ~]#
you will see if I change order of parameter result also change.If I put xxx to be first parameter the error message will be shown before output.but if I put xxx to be second parameter error message will be shown after "filecontent".It result the same everytime so I am sure It is not timing issue.but I think cat command execute parameter from left to right
I can explain your result
Code:
$ cat file xxx 2>stderr 1>stderr
$ cat stderr
cat: xxx: No such file or directory
"filecontent" is written to terminal first from offset 0,after "cat: xxx: No such file or directory" is also written to offset 0 too.Because second string is longer than "filecontent" so "filecontent" is completely overwrite by second error message.if you change content in a "file".Make it longer than error message you will see some string from output some string from error message
Code:
[root@localhost ~]# cat file xxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
cat: xxx: No such file or directory
[root@localhost ~]# cat file xxx 1>stderr 2>stderr
[root@localhost ~]# cat stderr
cat: xxx: No such file or directory
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[root@localhost ~]#
You see "xxx....xx" on second line because when error message was written on output It also append '\n' .Actually it is "cat: xxx: No such file or directory\n".
Let try!!!
So I confuse what make first example and second example different?