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

Detailed steps for installing and configuring mysql 5.6.21

1. Overview MySQL version: 5.6.21 Download addres...

MySQL transaction control flow and ACID characteristics

Table of contents 1. ACID Characteristics Transac...

MySQL 5.7.18 release installation guide (including bin file version)

The installation process is basically the same as...

JavaScript jigsaw puzzle game

This article example shares the specific code of ...

Implementation of rewrite jump in nginx

1. New and old domain name jump Application scena...

MySQL: mysql functions

1. Built-in functions 1. Mathematical functions r...

Detailed description of ffmpeg Chinese parameters

FFMPEG 3.4.1 version parameter details Usage: ffm...

Detailed graphic explanation of sqlmap injection

Table of contents 1. We found that this website m...

Five practical tips for web form design

1. Mobile selection of form text input: In the te...

Javascript closure usage scenario principle detailed

Table of contents 1. Closure 2. Closure usage sce...

Script to quickly list all host names (computer names) in the LAN under Linux

Recently, I have a need to list all host names in...

Solution to inserting a form with a blank line above and below

I don't know if you have noticed when making a...

mysql5.6.zip format compressed version installation graphic tutorial

Preface: MySQL is a relational database managemen...

Detailed explanation of HTML area tag

The <area> tag defines an area in an image ...

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