批处理在for里用if语句
@echooff&setlocalenabledelayedexpansionfor/f"delims="%%min(3.txt)do(setaa=%%mif!aa!=1...
@echo off &setlocal enabledelayedexpansion
for /f "delims= " %%m in (3.txt) do (
set aa=%%m
if !aa!=1032
goto :a
else
goto :b
:a
set aa=!aa:1032=正在共享,表示两者连接着!
echo !aa!
:b
echo !aa!
)
pause
以下是3.txt的文件内容
1032 ESTABLISHED
1166 CLOSE_WAIT
1250 LAST_ACK
1292 TIME_WAIT
1300 TIME_WAIT
1336 SYN_SENT
3309 ESTABLISHED
3328 ESTABLISHED
3850 ESTABLISHED
1746 ESTABLISHED
1747 ESTABLISHED 展开
for /f "delims= " %%m in (3.txt) do (
set aa=%%m
if !aa!=1032
goto :a
else
goto :b
:a
set aa=!aa:1032=正在共享,表示两者连接着!
echo !aa!
:b
echo !aa!
)
pause
以下是3.txt的文件内容
1032 ESTABLISHED
1166 CLOSE_WAIT
1250 LAST_ACK
1292 TIME_WAIT
1300 TIME_WAIT
1336 SYN_SENT
3309 ESTABLISHED
3328 ESTABLISHED
3850 ESTABLISHED
1746 ESTABLISHED
1747 ESTABLISHED 展开
1个回答
展开全部
for循环中不要使用卜纤goto语句,巧弊配否则就回不来了
直接使用if就好了:
::══代══码══开══始═══
@echo off &setlocal enabledelayedexpansion
for /f "delims= " %%m in (3.txt) do (
set aa=%%m
if !aa!==1032 (set aa=%aa:1032=正在共享,表示两孝指者连接着%
echo !aa!) else echo !aa!
)
pause
::Coded By escortmnm from VBS团队
::══代══码══结══束═══
直接使用if就好了:
::══代══码══开══始═══
@echo off &setlocal enabledelayedexpansion
for /f "delims= " %%m in (3.txt) do (
set aa=%%m
if !aa!==1032 (set aa=%aa:1032=正在共享,表示两孝指者连接着%
echo !aa!) else echo !aa!
)
pause
::Coded By escortmnm from VBS团队
::══代══码══结══束═══
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询