1

I need a simple .bat file to determine are there duplicate lines in my 2 text files. I don't need the dupes deleted or even displayed, I only need to know do they exist or not.

Files look like this:

name@gmail.com

blahblah@yahoo.com

iwjeuiwedjdjui@co.uk

john@aol.com

...

Thanks in advance for simple help instead of flaming and trying to make me look stupid.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Rajesh Muntari
  • 45
  • 1
  • 2
  • 5

3 Answers3

1
findstr /x /g:"filename1" "filename2"

Will find the lines that exist in both files if they exactly match and display them.

findstr /x /g:"filename1" "filename2">nul
if not errorlevel 1 echo found some

will display found some if at least one line matches. The >nul suppresses output from the findstr

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • You should add the `/L` option to force a literal search, else the dot will likely trigger a regex search. You should also add the `/I` flag, as most email systems ignore case. `/I` also prevents [this FINDSTR bug](https://stackoverflow.com/q/8844868/1012053) from being an issue. – dbenham Oct 10 '17 at 18:52
0

On Linux, execute this command

cat file1.txt file2.txt | sort | uniq -c | sort -nr

On Windows, actually not sure because I don't have a windows machine but try one of the following:

Windows PowerShell to find duplicate lines in a file

Remove Duplicate Lines from Text File using Windows batching

0

You can also use: nin f1.txt f2.txt -m to get file/pipe intersection. see following screenshot. Use -A to hide summary info of nin.exe.

nin.exe is a single portable exe (about 1.3MB) to get intersection set or difference set between 2 files or a file and a pipe by lines or keys. See nin.exe in my open project https://github.com/qualiu/msr tools directory or built-in doc like: https://qualiu.github.io/msr/usage-by-running/nin-Windows.html

Get files intersection set

Quanmao
  • 92
  • 5