I have 2 files and I want to find the difference and output only what is not inside ex2
If use grep -Ff ex2.txt ex1.txt
, it shows me a b c d
, if I use the same command with -v
there is not output. Why with does the first command also output d
?
What would be the easiest way to do this? Is grep suitable for this? Maybe diff maybe a script that would read each line and output if it's there or not?
cat ex1.txt
a
b
c
d
cat ex2.txt
a
b
c
Edit---my output shows up like this:
cat ex2.txt
a
b
c
cat ex1.txt
a
b
c
d
grep -vf ex2.txt ex1.txt
grep -f ex2.txt ex1.txt
a
b
c
d
ex2.txt
also contains an empty line which would tell grep to look for the empty string and the empty string can be found in any line.ex1
.