1

My question is how would I hide all text above the last line?
Somehow delete the text of the first part and then only show an echo of the last line - that still has user input functionality though.

[=  ]
[== ]
[===]
"last line with any text" (Y/N)?

Is there any rule I could add to a batch command that would show only the last line of the current command text result in the window?

atereou
  • 359

2 Answers2

1

Don't use cmd and use powershell instead. Get-Content cmdlet (and its aliases cat and gc) has a Tail option to do this

Get-Content file_path -Tail 1

If the text is the result of another command then use Select-Object or its select alias

your_command | Select-Object -Last 1

If you really need to use cmd then run the command from PowerShell like this

powershell -Com "gc file_path -Tail 1"
powershell -Com "your_command | select -Last 1"

If you have some kind of POSIX environments on your system wsl/wsl2 or cygwin then just use tail:

cat file | tail -n 1
your_command | tail -n 1
tail file -n 1

See also

phuclv
  • 30,396
  • 15
  • 136
  • 260
0
  • To delete/remove used lines you can use the solution from @LotPings in this answer, in additional, you also can use this in base64 decoded by Certutil
@echo off

title <nul && title Q1575583

call %:^0 && setlocal EnableDelayedExpansion

for /L %%L in (1 1 4)do echo\Line 0%%L

%APPDIR%timeout.exe -1 >nul type "%temp%_bs.bin" type "%temp%_bs.bin"

%APPDIR%timeout.exe -1 >nul echo/Line 06

%APPDIR%timeout.exe -1 >nul type "%temp%_bs.bin"

%APPDIR%timeout.exe -1 >nul echo/Line 07

%APPDIR%timeout.exe -1 >nul type "%temp%_bs.bin"

%APPDIR%timeout.exe -1 >nul type "%temp%_bs.bin"

2>nul del/Q /F "%temp%_bs.bin" endlocal & goto=:EOF

%:^0 >nul 2>&1 del /q /f "%temp%_bs.bin" >nul 2>&1 "%APPDIR%Certutil.exe" -decode -f "%~f0" "%temp%_bs.bin" & exit /b :: <-----BEGIN ._bs.bin ----- G1sxRhtbMEobWzFGG1swSg0K== -----END ._bs.bin -----> ::

  • Outputs:

enter image description here

  • About the strings in Base64 in this bat/cmd decoded in file "%temp%\_bs.bin"

enter image description here

Io-oI
  • 9,237