重定向多个stdins? [英] Redirecting Multiple stdins?
问题描述
我有三个文件命名为一,二,三。
I have three files named One, Two, Three.
一个包含了:
1
3
2
二载:
4
6
5
三载:
7
9
8
当我给下面的命令:
$sort < One < Two < Three
我得到的输出:
7
8
9
但是,当我给下面的命令:
But when I give the following command:
$sort One Two Three
我得到的输出中:
I get the ouput:
1
2
3
4
5
6
7
8
9
谁能请阐明什么exaclty发生在这里的光?为什么选自1和2的输入没有考虑到在第一命令
Can anyone please shed light on what exaclty is happening here? Why does the input from 1 and 2 not taken into consideration in the first command?
推荐答案
您的命令是一样的:
sort 0<1 0<2 0<3
(文件描述符0是标准输入)
(file descriptor 0 is standard input)
在重定向它们出现的顺序进行处理,由左到右。结果排序
命令本身看不出任何的文件。结果庆典
打开文件 1
, 2
, 3
在文件描述符0
一个接一个。结果
所以,正确的最多一个覆盖离开的。结果
最后,排序
从文件描述符0
这是绑定到文件 3 $读C $ C>。
Redirections are processed in the order they appear, from left to right.
sort
command itself cannot see any of those files.
bash
open file 1
,2
,3
at file descriptor 0
one by one.
So the right most one override left ones.
At last, sort
read from file descriptor 0
which is bind to file 3
.
这篇关于重定向多个stdins?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!