This other question is excellent for joining two files. I need to do sort of the opposite. I need to remove lines from File A that are in File B, using powershell.
This question is similar to this other question, except that question is for unix and this is for Windows 7 powershell.
The files are hosts files. Each one has lines consisting of:
127.0.0.1 host.domain.com
or
0.0.0.0 host.domain.com
or
# this is a comment
Files may have up to 200,000 lines. Spaces and tabs may be present.
Although I prefer it to be preserved, order does not effect function.
Here are some examples of hosts files:
- https://adaway.org/hosts.txt
- https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext
- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
- https://hosts-file.net/ad_servers.txt
- http://winhelp2002.mvps.org/hosts.txt
- http://someonewhocares.org/hosts/hosts
(Don't worry about 0.0.0.0
vs 127.0.0.1
for this question.)