Skip to main content
Cleaned the question. Added some highlighting.
Source Link

I have two files.
Match

Match the first1st column of first file to first1st column of second file and print entire line of the second file
Second.

Second file is a tab<tab> separated file. I

I have tried many awkawk one liners, but all remove duplicate values. like ALike A and CC here. I want to preserve these.
 

File 1File 1:

A B  C D A C 

File 2File 2:

A abc B cde C abe D acc 

Output:

A abc B cde C abe D acc A abc C abe 

I have two files.
Match the first column of first file to first column of second and print entire line of the second file
Second file is a tab separated file. I have tried many awk one liners but all remove duplicate values. like A and C here. I want to preserve these.
 

File 1

A B  C D A C 

File 2

A abc B cde C abe D acc 

Output:

A abc B cde C abe D acc A abc C abe 

I have two files.

Match the 1st column of first file to 1st column of second file and print entire line of the second file.

Second file is a <tab> separated file.

I have tried many awk one liners, but all remove duplicate values. Like A and C here. I want to preserve these.

File 1:

A B C D A C 

File 2:

A abc B cde C abe D acc 

Output:

A abc B cde C abe D acc A abc C abe 
added 6 characters in body
Source Link
cuonglm
  • 158.2k
  • 41
  • 342
  • 420

I have two files.
Match the first column of first file to first column of second and print entire line of the second file
Second file is a tab separated file. I have tried many awk one liners but all remove duplicate values. like A and C here. I want to preserve these.

File 1
A
B
C
D
A
C

A B C D A C 

File 2
A abc
B cde
C abe
D acc

A abc B cde C abe D acc 

Output:
A abc
B cde
C abe
D acc
A abc
C abe

A abc B cde C abe D acc A abc C abe 

I have two files.
Match the first column of first file to first column of second and print entire line of the second file
Second file is a tab separated file. I have tried many awk one liners but all remove duplicate values. like A and C here. I want to preserve these.

File 1
A
B
C
D
A
C

File 2
A abc
B cde
C abe
D acc

Output:
A abc
B cde
C abe
D acc
A abc
C abe

I have two files.
Match the first column of first file to first column of second and print entire line of the second file
Second file is a tab separated file. I have tried many awk one liners but all remove duplicate values. like A and C here. I want to preserve these.

File 1

A B C D A C 

File 2

A abc B cde C abe D acc 

Output:

A abc B cde C abe D acc A abc C abe 
Source Link
user3543389
  • 195
  • 1
  • 1
  • 5

Match first fields of two tab separated files and print matching values

I have two files.
Match the first column of first file to first column of second and print entire line of the second file
Second file is a tab separated file. I have tried many awk one liners but all remove duplicate values. like A and C here. I want to preserve these.

File 1
A
B
C
D
A
C

File 2
A abc
B cde
C abe
D acc

Output:
A abc
B cde
C abe
D acc
A abc
C abe