I had quite simple task - compare two lists of hosts and check if hosts from first one are also on the second one. I started with diff
:
diff -u biglist.txt hosts_to_check.txt | grep -E "^\+"
It was fine but output needs some filtering to get what I want.
I’ve found another example with grep
:
grep -Fxv -f biglist.txt hosts_to_check.txt | sort -n
This will search for all lines in hosts_to_check.txt which don’t match any line in biglist.txt. So after this I’ve got list of hosts that I have to check. That’s exactly what I need 😄