Monday, December 23, 2013

Join Linux Command With Examples

Linux Command Join With Examples

Command: join

Command Usage: join lines of two files on a common field

Syntax: $  join [OPTION]... FILE1 FILE2

Examples:

1. To find options and help info of this command

    $ join --help

2.  $ cat > file1.txt
     1 india
     2 uk
     3 us
     4 nepal
     5 australia

     $ cat > file2.txt
     1 newdelhi
     2 london
     3 washington
     4 kathmandu
     5 canberra

     to join file 1 and file 2 which is sorted

     $ join file1.txt file2.txt

     1 india newdelhi
     2 uk london
     3 us washington
     4 nepal kathmandu
     5 australia canberra

     If the input is not sorted lines cannot be joined, a warning message will be given.

3. To ignore cases when comparing file fields

    $ join -i file1.txt file2.txt

4. To verify that input is sorted

    $ join --check-order file1.txt file2.txt

5. To not to check that input is sorted

    $ join --nocheck-order file1.txt file2.txt

6. To print unpairable lines

    $ join -a1 file1.txt file2.txt

7. To print only unpaired lines

    $ join -v1 file1.txt file2.txt

8. To print help info of this command

    $ join --help

Join Linux Command With Examples

No comments:

Post a Comment

Linux Tips and tricks,Online Linux Helpers