批处理文件编写,去掉重复的ip段

来源:百度知道 编辑:UC知道 时间:2024/06/23 17:29:57
我扫到了ip段之后 如何编写一个批处理文件将 重复的ip段删除啊

例子:
61.135.1.1 61.135.254.254
211.151.1.1 211.151.254.254
202.108.1.1 202.108.254.254
202.108.1.1 202.108.254.254 整理此段ip地址使其曲调重复的ip段变为:
61.135.1.1 61.135.254.254
211.151.1.1 211.151.254.254
202.108.1.1 202.108.254.254

for /f "delims=" %%i in (a.txt) do type b.txt|find "%%i" ||echo %%i >>b.txt

a.txt生成b.txt,去重复,不改变原次序哦~~~ LS不知道为什么会变次序。

:: a.txt 为原文本,b.txt 是处理后的。
@echo off
cd.>b.txt
for /f "tokens=1,2 delims= " %%i in (a.txt) do (set /a n+=1&set "s=%%i %%j"&call :pd)
pause&exit

:pd
<"a.txt" more +%n%|find "%s%"||echo %s% >>b.txt