Wednesday, 31 May 2017

How to use Join Command in Linux

Join command combines lines from two files based on a common field.
In the example below, we have two files – employee.txt and salary.txt. Both
have employee-id as common field.
 So, we can use join command to combine

the data from these two files using employee-id as shown below.

$ cat employee.txt
100
200
300
400
Jason Smith
John Doe
Sanjay Gupta
Ashok Sharma

$ cat bonus.txt
100
200
300
400
$5,000
$500
$3,000
$1,250

$ join employee.txt bonus.txt
100
200
300
400
Jason Smith $5,000
John Doe $500
Sanjay Gupta $3,000
Ashok Sharma $1,250

No comments:

Post a Comment

What is PS2 - Continuation Interactive Prompt in Linux

A very long command can be broken down to multiple lines by giving \ at the end of the line. The default interactive prompt for a multi-lin...