Originally posted by willsort at 2006-2-28 16:40:
Re 3742668:
兄的方法确实有效,然而此方法仅仅适用于b完全包含a中所有文本的情况,如果a中有b中不存在的文本行,那么这些行将不会记入输出砮..
看了这段话是吃也吃不好,睡也睡不好,苦思冥想终于凑了一篇出来,望willsort指正:
@echo off
if exist 1和2都有.txt echo y | del 1和2都有.txt
if exist 1有2没有.txt echo y | del 1有2没有.txt
if exist 2有1没有.txt echo y | del 2有1没有.txt
copy 1.txt tmp.txt
:same
set a=
set /p a=<tmp.txt
if "%a%" == "" goto different
findstr /v %a% tmp.txt > temp.txt
type temp.txt >tmp.txt
findstr %a% 2.txt >>tmp1.txt
goto same
:different
findstr /v /g:tmp1.txt 1.txt >1有2没有.txt
findstr /v /g:tmp1.txt 2.txt >2有1没有.txt
:end
ren tmp1.txt 1和2都有.txt
echo y | del tmp.txt
echo y | del temp.txt
ps:本来自认为算是比较精益求精,追求完美的人了,但是与兄相比,惭愧之至啊
Last edited by 3742668 on 2006-3-1 at 16:41 ]