![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-07 18:09 |
共 48,041 主题排行 / 350,128 发帖 / 今日 3 篇 / 48,252 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 比较两个文本文件是否相同 |
| 可打印版本 1,425 / 8 |
| 第1楼 bobo247 | 发表于 2008-03-11 10:31 |
| 初级用户 发帖 14 积分 34 | |
|
比较两个文本文件是否相同 有两个文本文件,想要比较他们是否相同,比较的对象以行为单位。这两个文件的行号可以不一样,只要行的内容一样,就可以判定相同。把结果输出来,相同或者不同的字样,在dos屏幕上反映出来。
比如说: |
|
| 第2楼 bobo247 | 发表于 2008-03-11 10:36 |
| 初级用户 发帖 14 积分 34 | |
|
不如说
文件1.txt里面的行是: 1234||abc||CC 0987||bnsc||txt oquigh||bnvgh||yox 文件2.txt里面的行是: oquigh||bnvgh||yox 1234||abc||CC 0987||bnsc||txt 要判断这两文件相等如何做,请大虾指教 |
|
| 第3楼 5872169 | 发表于 2008-03-11 10:47 |
| 高级用户 发帖 474 积分 959 | |
|
FC命令,查询FC /?
|
|
| 第4楼 bobo247 | 发表于 2008-03-11 10:52 |
| 初级用户 发帖 14 积分 34 | |
|
小弟是初学者,请详细地说
|
|
| 第5楼 bat-zw | 发表于 2008-03-11 12:37 |
| 金牌会员 发帖 1,276 积分 3,105 | |
|
代码如下:
@echo off fc 1.txt 2.txt if errorlevell o goto show/此句即为判断两文件大小是否相同,是就转向show标签。 go to :eof :show echo 这两个文件大小一样 goto :eof [ Last edited by zw19750516 on 2008-3-11 at 12:41 PM ] |
|
| 第6楼 fastslz | 发表于 2008-03-11 13:35 |
| 铂金会员 发帖 2,315 积分 5,493 来自 上海 | |
|
真晕~
日复一日的~重复话题 搜索 |
|
| 第7楼 plp626 | 发表于 2008-03-11 14:05 |
| 银牌会员 发帖 1,020 积分 2,278 | |
|
批处理弄这个太差了,
只知道findstr做这个还行,但是行太长了(>127个字符)就不行了 比较两个文件内容,将不同的行显示出来: |
|
| 第8楼 HAT | 发表于 2008-03-11 14:15 |
| 版主 发帖 5,017 积分 9,023 | |
|
Microsoft Windows XP
(C) Copyright 1985-2001 Microsoft Corp. C:\>fc /? Compares two files or sets of files and displays the differences between them FC ] filename1 filename2 FC /B filename1 filename2 /A Displays only first and last lines for each set of differences. /B Performs a binary comparison. /C Disregards the case of letters. /L Compares files as ASCII text. /LBn Sets the maximum consecutive mismatches to the specified number of lines. /N Displays the line numbers on an ASCII comparison. /OFF Do not skip files with offline attribute set. /T Does not expand tabs to spaces. /U Compare files as UNICODE text files. /W Compresses white space (tabs and spaces) for comparison. /nnnn Specifies the number of consecutive lines that must match after a mismatch. filename1 Specifies the first file or set of files to compare. filename2 Specifies the second file or set of files to compare. |
|
| 第9楼 suntb | 发表于 2008-03-11 18:58 |
| 高级用户 发帖 277 积分 581 | |
|
@echo off
sort 1.txt>>t1.txt sort 2.txt>>t2.txt fc t1.txt t2.txt /n pause |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |