有二个*.txt的文档, 每个文档有几十万行记录(文档内的每行记录都以 " ," 为分隔), 可不可以用批处理去把它们不相同一的放到别的文档呢?
[ Last edited by xmi on 2008-6-25 at 10:33 PM ]
[ Last edited by xmi on 2008-6-25 at 10:33 PM ]
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
gawk "ARGIND==1{a}ARGIND>1&&!($0 in a){print $0}" a.txt b.txt >>c.txt
@echo off
rem 查找2.txt与1.txt中不同的行
findstr /v /g:1.txt 2.txt>3.txt
start 3.txt
C:\Test>gawk --hlep
Usage: gawk -f progfile file ...
Usage: gawk "program" file ...
POSIX options: GNU long options:
-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val
-m val
-W compat --compat
-W copyleft --copyleft
-W copyright --copyright
-W dump-variables --dump-variables
-W gen-po --gen-po
-W help --help
-W lint --lint
-W lint-old --lint-old
-W non-decimal-data --non-decimal-data
-W profile --profile
-W posix --posix
-W re-interval --re-interval
-W source=program-text --source=program-text
-W traditional --traditional
-W usage --usage
-W version --version
To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.
@echo off&setlocal enabledelayedexpansion
rem 查找1.txt与2.txt的不同之处
for /f "delims=" %%a in (1.txt) do (
for %%i in (%%a) do (
set "flag="
findstr "%%i" 2.txt>nul&&set flag=A
if not defined flag echo %%i>>3.txt
)
)
start 3.txt
Originally posted by HAT at 2008-6-25 11:19 PM:
看帮助
gawk "ARGIND==1{a}ARGIND>1&&!($0 in a){print $0}" a.txt b.txt >>c.txt , 成功抓到.万分谢意!Originally posted by zw19750516 at 2008-6-25 11:07 PM:
@echo off
rem 查找2.txt与1.txt中不同的行
findstr /v /g:1.txt 2.txt>3.txt
start 3.txt
ps:就是效率不怎么样
[ Last edited by zw19750516 on 2008-6-25 at 11:11 PM ]
Originally posted by lxmxn at 2008-6-26 12:19 AM:
几十万行,我想是不是可以导入到数据库中用SQL来的快些?