Join


From Linuxconfig.org

Jump to: navigation, search

Name

join - join lines of two files on a common field

Synopsis - man page

join [OPTION]... FILE1 FILE2

Frequently used options

-j FIELD
   equivalent to `-1 FIELD -2 FIELD'
-1 FIELD
   join on this FIELD of file 1
-2 FIELD
   join on this FIELD of file 2

Examples

Join command can be as a simple database join table. Suppose that we have two following files, file1:

$ echo -e "0001 =\n0010 =\n0011 =\n0100 =\n0101 =\n0111 =" | nl > file1
Image:join01.gif
$ echo -e "one\ntwo\nthree\nfour\nfive\nsix" | nl > file2
Image:join02.gif

now we can use join command to join those two files:

$ join -j 1 file1 file2
Image:join03.gif
Personal tools
Linux Commands