Batch file to output last line of findstr

前端 未结 2 1639
一整个雨季
一整个雨季 2021-01-27 01:26

I am trying to find a list of machines in files in folders, and print out the last line of the output only.

@echo off
for /f %%a in (computers.txt) do findstr /x         


        
相关标签:
2条回答
  • 2021-01-27 02:09
    setLocal enableDelayedExpansion
    for /f %%a in (computers.txt) do for /f "tokens=*" %%A in ('findstr /xs "%%a"') do set lastFound=%%A
    echo !lastFound!
    
    0 讨论(0)
  • 2021-01-27 02:11
    @echo off
    setlocal enableextensions disabledelayedexpansion
    for /f %%a in (computers.txt) do (
        set "line="
        for /f "tokens=*" %%b in ('findstr /xs "%%a" *') do set "line=%%b"
        setlocal enabledelayedexpansion
        echo(!line!
        endlocal
    )
    pause
    endlocal
    
    0 讨论(0)
提交回复
热议问题