$ ls tmp.txt groad.net > file.txt 2>1
$ cat file.txt
tmp.txt
$ ls -l
total 24
-rw-rw-r-- 1 beyes beyes 55 Nov 15 23:15 1
$ cat 1
ls: cannot access groad.net: No such file or directory
$ ls tmp.txt groad.net > file.txt 2>&1
$ cat file.txt
ls: cannot access groad.net: No such file or directory
tmp.txt
$ ls tmp.txt groad.net 2>&1 > file.txt
ls: cannot access groad.net: No such file or directory
$ cat tmp.txt
hello
open("myfile.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
dup2(3, 1) = 1
close(3) = 0
dup2(1, 2) = 2
dup2(1, 2) = 2
open("myfile.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
dup2(3, 1) = 1
close(3) = 0
write(2, "ls: ", 4) = 4
write(2, "cannot access groad.net", 23) = 23
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |