I am trying to compare a list of IP's and output the difference by using the findstr command in Windows and am having difficulty getting it to work. The command I am using is:
EDIT: My objective is to compare IP's that were scanned successfully to IP's that were scanned successfully with authentication achieved and output it the files that aren't in IPsSuccessfullyScannedwithAuthentication.txt but are in IPsSuccessfullyScanned.txt to IPsSuccessfullyScannedButNotAuthenticated.txt.
Let's say IPsSuccessfullyScanned.txt contain
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8-192.168.0.12
and IPsSuccessfullyScannedwithAuthentication.txt (which are the IP's that authenticated and were successfully scanned) contain
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.6
192.168.0.8-192.168.0.10
192.168.0.12
My IPsSuccessfullyScannedButNotAuthenticated.txt should have this:
192.168.0.5
192.168.0.7
192.168.0.11
findstr /vixg:IPsSuccessfullyScanned.txt IPsSuccessfullyScannedwithAuthentication.txt > IPsSuccessfullyScannedButNotAuthenticated.txt
What I am trying to achieve is very similar to this post:
.bat file to compare two text files and output the difference
Here is my issue though, the file size in the IPs2.txt is 720 bytes. When I researched about the findstr command, I found out that when doing a regular expression search, the maximum search string length is 254 bytes. A regular expression with length between 255 bytes and 511 bytes will result in a FINDSTR: Out of memory error with ERRORLEVEL 2.
A regular expression length >511 bytes results in the FINDSTR: Search string too long. error. (which is the error I'm currently getting).
My question is: What alternatives are out there that I can use to be able to compare the two text files? If there are any other suggestions to resolve my issue as easy as possible, even a bat file can help if possible.
References:
http://ss64.com/nt/findstr-escapes.html
What are the undocumented features and limitations of the Windows FINDSTR command?