作者:qinchun36 | 时间:2008-07-22 17:24 | 标题:[已结]去掉文本文档中相同的行
文本文档 a.txt 里面有些行是完全相同的,
我想编个批处理把那些多余的相同的去掉,
使得弄完以后所有的都不相同.
怎么办啊, 我试了下没办法, 象下面这样的:
for /f %%i in (a.txt) do echo %%i>>new.txt&set str=%%i&for /f %%j in (a.txt) do if %%j==%str% set %%j=nul
[ Last edited by HAT on 2008-10-30 at 23:23 ]
作者:fuuma | 时间:2008-07-23 16:05
@echo off
if exist new.txt del new.txt
sort/r<a.txt>temp.txt
setlocal enabledelayedexpansion
set cat=
set dog=
set/a cnt=-1
for /f %%i in (temp.txt) do (
set cat=!dog!
set dog=%%i
set/a cnt+=1
if not "!cat!" equ "" if !dog! neq !cat! (echo !cat! >>new.txt&set/a cnt=0)
)
if !dog! neq !cat! (echo !dog! >>new.txt) else (
echo !cat! >>new.txt)
if exist temp.txt del temp.txt
作者:qinchun36 | 时间:2008-09-05 13:00
Originally posted by fuuma at 2008-7-23 04:05 PM:
@echo off
if exist new.txt del new.txt
sort/r<a.txt>temp.txt
setlocal enabledelayedexpansion
set cat=
set dog=
set/a cnt=-1
for /f %%i in (temp.txt) do (
set cat=!dog!
set dog=%%i
s ...
谢了啊 ,哈哈
作者:nanhezzb | 时间:2008-09-07 16:26
太复杂啊,可以考虑find命令。
作者:HAT | 时间:2008-09-07 18:08 | 标题:Re 4楼
是这个意思吗?
@echo off
type nul>b.txt
for /f "delims=" %%a in (a.txt) do (
findstr /x /c:"%%a" b.txt 2>nul||echo %%a>>b.txt
)
作者:qinchun36 | 时间:2008-10-30 23:14
Originally posted by HAT at 2008-9-7 06:08 PM:
是这个意思吗?
@echo off
type nul>b.txt
for /f "delims=" %%a in (a.txt) do (
findstr /x /c:"%%a" b.txt 2>nul||echo %%a>>b.txt
)
真是这样啊!!
能解释下吗,太高深了看不懂
尤其是 。。。 2>nul||echo %%a>>b.txt 。。。
[
Last edited by qinchun36 on 2008-10-30 at 23:16 ]
作者:HAT | 时间:2008-10-30 23:23 | 标题:Re 6楼