In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use join commands in linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use join commands in linux" this article.
The Linux join command is used to connect the lines in two files with the same contents of the specified fields, find out the lines in the two files with the same contents in the specified fields, merge them, and output them to the standard output device.
1. Brief introduction to Command
splices two files horizontally by Cartesian product according to the same fields specified, and outputs them to standard output. By default, the join field delimiter is a space or Tab. When join, two files need to be sorted according to a field.
Cartesian product refers to the set of ordered pairs formed by the combination of X and Y members of two sets. For example, if the set X = {a _ r _ b}, Y = {0m _ 1 ~ 2}, then
X × Y = {(a, 0), (a, 1), (a, 2), (b, 0), (b, 1), (b, 2)} Y × X = {(0, a), (0, b), (1, a), (1, b), (2, b)} 2. Command format
Join [OPTIONS] FILE1 FILE2 when FILE1 or FILE2 are hyphens-(both cannot be -), then the content is read from standard input.
3. The option description-a FILENUM displays lines that do not have the same field in the file in addition to the original output. The value of FILENUM is 1 or 2, corresponding to FILE1 and FILE2-e EMPTY, respectively. If the specified column is not found in FILE1 and FILE2, the string-I in the option is filled in the output. When-- igore-case compares the column contents, ignoring the case-j FIELD is equivalent to-1 FIELD- 2 FIELD-o FORMAT displaying the results in the specified format-t CHAR specifies the delimiter of the input and output columns-v FILENUM acts like-a FILENUM. However, only the row-1 FIELD connection FILE1 specified columns that do not have the same columns in the file are displayed. FIELD takes 1 for the first column, 2 for the second column, and so on-2 FIELD connects the column specified by FILE2. FIELD takes 1 for the first column, 2 for the second column, and so on-- check-order default option to check whether files have been sorted-- nocheck-order does not check that files have been sorted-- help displays help and exits-- version displays version information and exits
4. Common examples
(1) connects two files, with the first column as the connection field by default.
# file1 content is as follows: lvlv dablelv 25zhangsan San 1 contains file2 content as follows: lvlv english 15lvlv math 75zhangsan math 14zhouxun english 45join file1 file2lvlv dablelv 25 english 15lvlv dablelv 25 math 75zhangsan San 12 math 14
(2) or take the above two files as an example, the display indicates that the connection is made according to the Chinese name of the first column.
Join-j 1 file1 file2# or join-1 1-2 1 file1 file2
(3) if you want to display lines that do not have the same fields, use-A1 or-a2 to specify the lines that display the first or second file.
Join-a2 file1 file2lvlv dablelv 25 english 15lvlv dablelv 25 math 75zhangsan San 12 math 14zhouxun english 45 / / shows that the unmatched lines in the file file2 are all the contents of the article "how to use join commands in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 211
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.