[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
@echo off
for /f "delims=" %%i in ('findstr /c "hello world" "aaa.txt"') do (
if not defined aaa set aaa=%%i
)
echo,"%aaa%"
pause

TOP

需要enabledelayedexpansion
需要清除set /p的内容,不然再次set /p时为空,就是上次的内容
  1. @echo off
  2. for /f %%i in (testin.txt) do (
  3. set "aaa=%%i"
  4. ..\ipmitool.exe xxx(参数)| findstr /c:"Product Serial" >tmp.txt
  5. setlocal enabledelayedexpansion
  6. echo,!aaa!>>result.txt
  7. set /p var=<tmp.txt
  8. echo,!var!>>result.txt
  9. echo,>>result.txt
  10. endlocal
  11. )
  12. pause
复制代码

TOP

返回列表