](https://gagor.pro/generic-cover.webp)
Comparing two lists in bash
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 😄
](https://gagor.pro/2014/01/change-default-wsus-port-from-8530-to-80-on-windows-server-2012/images/cover.webp)
](https://gagor.pro/2013/11/reset-user-password-in-your-own-ghost-blog/images/cover.webp)
