我在所有的帖子了找比较两个文件的不同并输出结果,完全没找到需要的内容,万般无奈,只能发个帖子了,
思路是这样的,我想比较1.TXT和2.TXT两个文件的不同并把结果输出到3.TXT
我有比较不同的代码,但似乎没啥效果,只能比较出一个不同!
代码如下:
@echo off
:: 把两个文件中的不同之处提取到某个文件中去
:: code by jm 2006-9-9 CMD@XP
cd.>3.txt
for /f "tokens=1* delims=:" %%i in ('findstr /n . 1.txt') do (
for /f "tokens=1* delims=:" %%x in ('findstr /n . 2.txt') do (
if %%i equ %%x if not "%%j"=="%%y" (>>3.txt echo 1:%%j&>>3.txt echo 2:%%y&>>3.txt echo.)
)
)
这代码看的不是很明白,麻烦高手帮忙写个简单的,我记得好象有一个高手写了个简单的,但找不到啊!麻烦各位了,这问题困惑了我很久了..........
─────────────────── 版务记录 ────────────────────
执行:lxmxn
操作:修改主题标题
─────────────────── 版务记录 ────────────────────
问题已经彻底解决,特别感谢DOS联盟热情的朋友给予的热情帮助!
Last edited by luckboy45 on 2007-5-30 at 06:56 PM ]
I searched through all the posts to find content about comparing the differences between two files and outputting the result, but I couldn't find the needed content at all. In desperation, I can only post.
The idea is like this: I want to compare the differences between two files 1.TXT and 2.TXT and output the result to 3.TXT
I have code for comparing differences, but it doesn't seem to work effectively; it can only compare one difference!
The code is as follows:
@echo off
:: Extract the differences between the two files to a certain file
:: code by jm 2006-9-9 CMD@XP
cd.>3.txt
for /f "tokens=1* delims=:" %%i in ('findstr /n. 1.txt') do (
for /f "tokens=1* delims=:" %%x in ('findstr /n. 2.txt') do (
if %%i equ %%x if not "%%j"=="%%y" (>>3.txt echo 1:%%j&>>3.txt echo 2:%%y&>>3.txt echo.)
)
)
I don't understand this code very well. Please help experts write a simple one. I remember that there was a master who wrote a simple one, but I can't find it! Please everyone. This problem has puzzled me for a long time..........
─────────────────── Moderation Record ────────────────────
Performer: lxmxn
Operation: Modify topic title
─────────────────── Moderation Record ────────────────────
The problem has been completely solved. Special thanks to the enthusiastic friends of the DOS Union for their warm help!
Last edited by luckboy45 on 2007-5-30 at 06:56 PM ]