Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the join command of Linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use the join command of Linux". In daily operation, I believe many people have doubts about how to use the join command of Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to use the join command of Linux". Next, please follow the editor to study!

Linux common command join command is used to connect two files with the same lines in the specified fields, find out the lines in the two files with the same contents in the specified fields, merge them, and then output them to the standard output device.

Syntax join [- I] [- a] [- e] [- o] [- t] [- v] [- 1] [- 2] [--help] [--version] [file 1] [file 2] parameters:

-an in addition to displaying the original output, it also displays lines in the instruction file that do not have the same field.

-e if the specified field cannot be found in [file 1] and [file 2], fill in the string in the option in the output.

The case difference is ignored when-I or-igore-case compares the contents of the field.

-o displays the results in the specified format.

-t uses the delimited characters of the field.

-v is the same as-a, but only lines in the file that do not have the same field are displayed.

-1 connects the fields specified in [file 1].

-2 connects the fields specified in [file 2].

-help displays help.

-version displays version information.

Instance connects two files.

To clearly understand the join command, first display the contents of the files testfile_1 and testfile_2 through the cat command.

Then compare the two files by default, connect the lines with the same contents of the specified fields in the two files, and enter the command in the terminal:

Join testfile_1 testfile_2 first looks at the contents of the files in testfile_1 and testfile_2:

Content in $cat testfile_1 # testfile_1 file Hello 95 # for example, the first column name in this example, the second column amount test 85 test 30 cmd@hdd-desktop:~$ cat testfile_2 # testfile_2 file content Hello 2005 # for example, the first column name in this example, the second column year Linux 2009 test 2006, and then use the join command to connect the two files, the result is as follows:

Content in $join testfile_1 testfile_2 # connection testfile_1, content in testfile_2 Hello 95 2005 # the location of file 1 and file 2 displayed after connecting Linux 85 2009 test 30 2006 has an impact on the output to standard output. For example, to interchange the two files in the command, enter the following command:

The final output of join testfile_2 testfile_1 in standard output will change, as shown below:

$join testfile_2 testfile_1 # change the file order to connect two files Hello 2005 95 # the content displayed after the connection Linux 2009 85 test 2006 30 here, on the "Linux join command how to use" the study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 0

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report