@echo off
set var2=58.56.77.233 www.yui.com
set var3=58.56.77.233
set var4=dddddddd
for /f "tokens=* delims= " %%j in (C:/WINDOWS/system32/drivers/etc/hosts) do set var=%%j&&echo %%j>>temp.txt
echo %var%|find "%var3%">>1.txt
echo dddddddd>>1.txt
echo %var2%
for /f "tokens=1 delims= " %%i in (1.txt) do (if %%i==%var3% (goto 2) else (goto 1))
pause
exit
:1
if %%i==%var4% (echo %var4%) else (echo %var2%>>temp.txt&&(for /f "tokens=* delims=" %%m in (temp.txt) do echo %%
m>>hosts))
goto 3
:2
for /f "tokens=* delims=" %%k in (temp.txt) do echo %%k>>hosts
goto 3
:3
copy hosts C:/WINDOWS/system32/drivers/etc/hosts
del 1.txt
del hosts
del temp.txt
pause
exit
【批处理】读取hosts文件 判断是否有制定字符
最新推荐文章于 2022-11-23 18:08:51 发布