Basic linux commands β Join
Here, we discuss about a command called βJoinβ.
join file_name1.txt file_name2.txt
Letβs assume file_name1.txt has the content like..,
1 Hi Everybody..,
2 We are going to launch a truck
And file_name2.txt has the content as.,
1 Have a pleasant morning!.
2 in India.
Now,using the above command the output we get.
1 Hi Everybody.., Have a pleasant morning!.
2 We are going to launch a truck in India.
It joins two file into a single file,by using join command.
NOTE :
There must be a common field should present.
i.e In both files, [ 1 and 2 ] were present and it has two lines.Those serial numbers are present in column one.
join -1 2 -2 1 file_name1.txt file_name2.txt
Letβs discuss what we done in this command.
In file_name1.txt
1 Hi Everybody..,
2 Today we are going to launch truck
And in file_name2.txt
Have a pleasant morning!. 1
in India. 2
The column [ 1 AND 2 ] were shuffled in the respective file.So,we must mention the common field as..,
ββ-1 1 -2 1 file_name1.txt file_name2.txtβ
NOTE :
-1 ==> refers file_name1.txt
1 ==> refers the column number 1
-2 ==> refers file_name2.txt
2 ==> refers the column number 2