The usage of the Linux basic command join
This article mainly explains "the usage of the Linux basic command join". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the basic Linux command join.
Join
Find the same fields in the two files, merge the two files according to the same fields, and display the merge results to standard output.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Join [options] file1 file2
2. List of options
Option
Description
-- version
Display command version information
-- help
Show help documentation
-a 1 or 2
Display lines that do not have the same fields in the file
-e string
If the specified string cannot be found in the file, fill in the string in the option in the output
-I |-- ignore-case
Ignore case
-j FIELD
Equivalent to "- 1 FIELD-2 FIELD"
-o format
Displays the results in the specified format
-t CHAR
Specify delimiter
-v 1 or 2
Same as-a, but only lines that do not have the same fields are displayed
-1 FIELD
Connect the fields specified in file 1
-2 FIELD
Connect the fields specified in file 2
-- check-order
Check that the input is sorted correctly, even if all input lines are repairable.
-- nocheck-order
Do not check whether the input is sorted correctly
3. Examples
1) merge two files into standard output
[root@192 weijie] # cat 1.c 2.c / / View the file
Hello world
I am david
Love linux
This code
Nihao ed
Hello linux
I am weijie
Love world
Hehe
Im join
[root@192 weijie] # join 1.c 2.c / / merge the same line
Hello world linux
I am david am weijie
Love linux world
2) display rows without the same field
[root@192 weijie] # join 1.c 2.c-v 1 / / displays lines in file 1 that do not have the same field
This code
Nihao ed
[root@192 weijie] # join 1.c 2.c-v 2 / / displays lines that do not have the same field in file 2
Hehe
Im join
At this point, I believe you have a deeper understanding of "the use of the Linux basic command join". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!