Batch: nested for variable cannot be compared -


i need compare 2 text files , lines appear in both of them. code:

@echo off /f "tokens=*" %%a in (%1.txt) (     /f "tokens=*" %%b in (%2.txt) (         echo %%a %%b         if %%a==%%b echo ok                      ) ) 

i test files a.txt (lines a, c , d) , b.txt (lines a, b , c). output:

a  b  c  c  c b  c c  d  d b  d c 

if substitute %%a==%%b %%a==a, output following:

a  ok                   b  ok                   c  ok                   c  c b  c c  d  d b  d c  

while test %%b==a instead, output same @ %%a==%%b.

it seems me %%b couldn't compared anything. doing wrong?

your code correct, second file (b.txt) has trailing spaces.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -