Linux uses join -a1 to merge two files

Linux uses join -a1 to merge two files

To merge the following two files, merge them together and merge them into 1.txt

# 1.txt
Jerry 20
Alice 30
David 40
# 2.txt
Jerry man
Alice woman
David 40

Merged 1.txt

Jerry 20 man
Alice 30 woman
David 40

The above files have the same characteristics, so they are merged, and the second column is missing. At this time, using join -a1 1.txt 2.txt can achieve the purpose well.

[root@host ~]# join -a1 1.txt 2.txt
Jerry 20 man
Alice 30 woman
David 40
  • -a: In addition to displaying the matched lines, also display the matching lines in the specified sequence number (1 or 2) file
  • -1: Match the FIELD field in file1

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Detailed explanation of upgrading Python and installing pip under Linux
  • How to use for loop combined with if to find files in Linux Shell directory
  • How to get the real path of the current script in Linux
  • Linux virtual memory settings tutorial and practice
  • Detailed usage of Linux text search command find
  • One question to understand multiple parameters of sort command in Linux
  • How to Fix File System Errors in Linux Using ‘fsck’
  • Linux editing start, stop and restart springboot jar package script example
  • How to deal with the prompt "Operation not permitted" when deleting files in Linux
  • Introduction to the use and disabling of transparent huge pages in Linux

<<:  Detailed explanation of possible problems in converting floating point data to character data in MySQL

>>:  Detailed explanation of the fish school algorithm in CocosCreator game

Recommend

A brief discussion on the correct approach to MySQL table space recovery

Table of contents Preliminary Notes Problem Repro...

Detailed explanation of how to use grep to obtain MySQL error log information

To facilitate the maintenance of MySQL, a script ...

Learn the basics of JavaScript DOM operations in one article

DOM Concepts DOM: document object model: The docu...

WeChat applet realizes the effect of shaking the sieve

This article shares the specific code of the WeCh...

How to use a field in one table to update a field in another table in MySQL

1. Modify 1 column update student s, city c set s...

Vue implements the drag and drop sorting function of the page div box

vue implements the drag and drop sorting function...

Vue realizes the palace grid rotation lottery

Vue implements the palace grid rotation lottery (...

Detailed tutorial on deploying Django project under CentOS

Basic Environment Pagoda installation service [Py...

The latest virtual machine VMware 14 installation tutorial

First, I will give you the VMware 14 activation c...

Detailed tutorial on using VMware WorkStation with Docker for Windows

Table of contents 1. Introduction 2. Install Dock...

JavaScript array deduplication solution

Table of contents Method 1: set: It is not a data...

Several navigation directions that will be popular in the future

<br />This is not only an era of information...

MySQL 8.0.2 offline installation and configuration method graphic tutorial

The offline installation method of MySQL_8.0.2 is...

Comprehensive analysis of MySql master-slave replication mechanism

Table of contents Master-slave replication mechan...

HTML+CSS+JS to implement the Don't Step on the Whiteboard game

Table of contents Background 1. Thought Analysis ...