❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Basic linux commands – Join

By: Gowtham G
13 February 2024 at 02:58

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

Basic linux commands – Join

By: Gowtham G
13 February 2024 at 02:58

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

❌
❌