HOW TO JOIN FILES IN LINUX

In this article we are going to learn how to join two or three files in linux.

Sometimes we keep records of employees , staff , students or members in different files but we want files should combine and show result of one person from two files or three files.

  • So first we will create one file  and name it as a.txt . Make sure you give numeric in front of names or details of that person . After writing evrything in that file press CTRL+D to save that file.
[root@localhost ~]# cat >a.txt
1 DEEPIT
2 NEHA
3 RAHUL
4 MARIE
5 BRAD
  • Now we another file (b.txt) to join it together . Same you have to press CTRL +D to save .
[root@localhost ~]# cat >b.txt
7406628159
8637357385
9836427965
7328767654
7527964576
  • Then we are going to combine information of two files and into new file Deepit.txt 
[root@localhost ~]# join a.txt b.txt>deepit.txt
  • You can check whether deepit.txt has been created or not.
[root@localhost ~]# ls
anaconda-ks.cfg  a.txt  b.txt  deepit.txt  Desktop  install.log  install.log.syslog
  • Now try to open deepit.txt and you will get information of both a.txt and b.txt file in deepit.txt file
[root@localhost ~]# cat deepit.txt
1 DEEPIT 7406628159
2 NEHA   8763735348
3 RAHUL  7284562746
4 MARIE  7472983486
5 BRAD   8346632946

So this how you can join two file into one .

IF you want to join three files, make three files and after that type 

[root@localhost ~]# join3 a.txt b.txt c.txt >deepit.txt

So your three files information will be in deepit.txt

This method is only been used to combine records and information of employees, staff, members , students etc . 

HOW TO REDUCE THE SIZE OF LVM(LOGICAL VOLUME) IN LINUX

HOW TO BREAK FILE INTO MANY FILES TO SECURE YOUR DATA

HOW TO HIDE YOUR ONLINE ACTIVITY FROM GOVERNMENT.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s