再加上剔除重复域名的代码:- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=5-13 delims=. " %%a in (hosts.txt) do (
- set /a n=0
- call :lp %%a %%b %%c %%d %%e %%f %%g %%h %%i
- )
- start new.txt&goto :eof
- :lp
- if "%1" neq "" (
- set /a n+=1&set "_!n!=%1"
- shift&goto lp
- )
- set /a a=n-1,b=a-1
- for %%k in (com cn net us) do (
- if "!_%n%!" equ "%%k" set "one=a"
- if "!_%a%!" equ "com" if "!_%n%!" equ "cn" set "two=a"
- )
- if defined one (
- if defined two (
- if not defined !_%b%!.!_%a%!.!_%n%! (
- echo !_%b%!.!_%a%!.!_%n%!>>new.txt
- set "!_%b%!.!_%a%!.!_%n%!=a"&set "two="
- )
- ) else (
- if not defined !_%a%!.!_%n%! (
- echo !_%a%!.!_%n%!>>new.txt
- set "!_%a%!.!_%n%!=a"&set "one="
- )
- )
- )
复制代码
[ 本帖最后由 batman 于 2009-2-16 10:16 编辑 ] |