Problem:
- Need to compare two files,
- removing the duplicate from the first file
- then appending the lines of file1 to file2
Illustration by example
Suppose, The two files are test1 and test2.
$ cat test2
www.xyz.com/abc-2
www.xyz.com/abc-3
www.xyz.com/abc-4
www.xyz.com/abc-5
www.xyz.com/abc-6
And test1 is
$ cat test1
www.xyz.com/abc-1
www.xyz.com/abc-2
www.xyz.com/abc-3
www.xyz.com/abc-4
www.xyz.com/abc-5
Comparing test1 to test2 and removing duplicates from test 1
Result Required:
$ cat test1
www.xyz.com/abc-1
and then adding this test1 data in to test2
$ cat test2
www.xyz.com/abc-2
www.xyz.com/abc-3
www.xyz.com/abc-4
www.xyz.com/abc-5
www.xyz.com/abc-6
www.xyz.com/abc-1
Solutions Tried:
join -v1 -v2 <(sort test1) <(sort test2)
which resulted into this (that was wrong output)
$ join -v1 -v2 <(sort test1) <(sort test2)
www.xyz.com/abc-1
www.xyz.com/abc-6
Another solution i tried was :
fgrep -vf test1 test2
which resulted nothing.