为什么unix实用程序连接会在不同的Linux发行版上产生不同的结果?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了为什么unix实用程序连接会在不同的Linux发行版上产生不同的结果?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1929字,纯文字阅读大概需要3分钟。
内容图文
![为什么unix实用程序连接会在不同的Linux发行版上产生不同的结果?](/upload/InfoBanner/zyjiaocheng/971/3825f674fcb142a8914b57bf750a9645.jpg)
我有两个排序文件:
cat file1
1
3
cat file2
C 1 D
B 2 E
A 3 F
我运行这个命令:
join -1 1 -2 2 -v2 file1 file2
使用GNU coreutils 6.9.92.4-f088d-dirt 2008年1月在Debian 4.3.2-1.1上我得到:
B 2 E
使用GNU coreutils 8.12.197-032bb 2011年9月在Ubuntu 4.4.3-4ubuntu5.1(Ubuntu精确(12.04.2 LTS))我得到:
2 B E
为什么我会得到不同的结果?为什么我不能在任何地方找到这种变化?以下是两个人力输出的内容:
-a FILENUM
print unpairable lines coming from file FILENUM, where FILENUM
is 1 or 2, corresponding to FILE1 or FILE2
-v FILENUM
like -a FILENUM, but suppress joined output lines
以下是我为每个Linux发行版获得相同答案所必须做的事情:
join -1 1 -2 2 -v2 -o 2.1,2.2,2.3 file1 file2
解决方法:
我找到了答案.以下是较新版本的info join输出的一部分:
`-o auto'
If the keyword `auto' is specified, infer the output format from
the first line in each file. This is the same as the default
output format but also ensures the same number of fields are
output for each line. Missing fields are replaced with the `-e'
option and extra fields are discarded.
Otherwise, construct each output line according to the format in
FIELD-LIST. Each element in FIELD-LIST is either the single
character `0' or has the form M.N where the file number, M, is `1'
or `2' and N is a positive field number.
A field specification of `0' denotes the join field. In most
cases, the functionality of the `0' field spec may be reproduced
using the explicit M.N that corresponds to the join field.
However, when printing unpairable lines (using either of the `-a'
or `-v' options), there is no way to specify the join field using
M.N in FIELD-LIST if there are unpairable lines in both files. To
give `join' that functionality, POSIX invented the `0' field
specification notation.
All output lines--including those printed because of any -a or -v
option--are subject to the specified FIELD-LIST.
虽然我仍然认为核心unix实用程序改变了版本之间的行为是不幸的,但神秘解决了.在使用新的Linux发行版时,这教会我重新阅读文档.
内容总结
以上是互联网集市为您收集整理的为什么unix实用程序连接会在不同的Linux发行版上产生不同的结果?全部内容,希望文章能够帮你解决为什么unix实用程序连接会在不同的Linux发行版上产生不同的结果?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。