2
votes

I have two text files file1.txt & file2.txt

file1.txt Contains :

                 a
                 b
                 c

file2.txt Contains :

                 a
                 b
                 c
                 d
                 e 
                 f

The Output Should be :

                  d
                  e
                  f

The command i'm trying to use is 'diff file2.txt file1.txt' It gives the common lines only.

2

2 Answers

1
votes

Assuming that the input files are sorted:

join -v 2 file1.txt file2.txt

Check man join for details on all the other things join can do for you.

1
votes

please try below ones

grep -vf file1.txt file2.txt

comm -13 file1.txt file2.txt

for diff you have to perform something extra

diff inp inp1 | grep '>' | cut -f2 -d' '