Question: I have output of 2 commands like:
op of first cmd:

```
A B
C D
E F
G H

```

op of second cmd:

```
I J
K L
M B

```

i want to merge both the outputs , and if a value in second column is same for both outputs, I'll take entry set from 1st output..
So , my output should be

```
A B
C D
E F
G H
I J
K L

```

//not taking (M B) sice B is already there in first entry(A B) , so giving preference to first output

can i do this using shell script , is there any command?

Answer: 
You can use awk:

```
awk 'FNR==NR{a[$2];print;next} !($2 in a)' file1 file2

A B
C D
E F
G H
I J
K L

```
If the order of entries is not important, you can `sort` on the 2nd column and uniquefy:

```
sort -u -k2 file1 file2

```

Both `-u` and `-k` are specified in [the POSIX standard](http://pubs.opengroup.org/onlinepubs/009695399/utilities/sort.html)

This wouldn't work if there are repeated entries in the 2nd column of file1.