Reputation: 15629
I have two files
File1.txt:
docker/registry:2.4.2
docker/rethinkdb:latest
docker/swarm:1.0.0
File2.txt:
docker/registry:2.4.1
docker/rethinkdb:1.0.0
docker/swarm:1.0.0
The output should be:
docker/registry:2.4.2
docker/rethinkdb:latest
In other words, every line in File1 that doesn't exist in File2 should be part of the output.
I have tried doing the following but it is not working.
diff File1.txt File2.txt
Upvotes: 2
Views: 48
Reputation: 37464
You could just use grep
for it:
$ grep -v -f file2.txt file1.txt
docker/registry:2.4.2
docker/rethinkdb:latest
If there are lots of rows in the files I'd probably use @user000001 solution.
Upvotes: 2
Reputation: 33387
With awk you can do:
awk 'NR==FNR{a[$0];next}!($0 in a)' file2 file1
Upvotes: 1