Merging two outputs in shell script
You can use awk:
awk 'FNR==NR{a[$2];print;next} !($2 in a)' file1 file2A BC DE FG HI JK 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
This wouldn't work if there are repeated entries in the 2nd column of file1.