从 windows 命令的输出中获取精确的单元格

getting exact cell from output of windows command

我在 win 2k12 服务器上 运行 netsh interface ipv4 show inter 命令,它给我的输出像

Idx     Met         MTU          State                Name
---  ----------  ----------  ------------  ---------------------------
  1          50  4294967295  connected     Loopback Pseudo-Interface 1
 16           5        1500  connected     vEthernet (New Virtual Switch)

我如何从输出的变量中获取 16 Idx。 通过 findstr Idx 它给出第一行。请给我解决方案。 提前致谢。

你可以这样做:

@echo off
For /f "tokens=1 delims= " %%a in ('netsh interface ipv4 show inter ^|find /I "1500"') do (
    set "Idx_Var=%%a" 
)
echo Idx_Var=%Idx_Var%
pause & exit