Home > database >  How to output multiple greater-than signs > (right angle brackets) with command ECHO?
How to output multiple greater-than signs > (right angle brackets) with command ECHO?

Time:04-30

In this case I want to output >>> with echo. But there is output first:

Press any key to continue . . .

After pressing a key is output next:

> was unexpected at this time.

Is there anything I can do to fix it?

The batch file is:

@echo off
setlocal EnableDelayedExpansion

set en="^>"
set rip=3
set "_in="
for /L %%i in (1,1,%rip%) do set "_in=!_in!%en%"
pause
call :dequote _in
:dequote
Set _in=%_in:"=%
goto fof
:fof
echo %_in%
pause

CodePudding user response:

To do it your way, it would be more like this:

@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion
Set "en=>"
Set "rip=3"
Set "_in="
For /L %%G In (1,1,%rip%) Do Set "_in=!_in!%en%"

Rem View any expanded variable string value.
Echo(!_in!
Pause

CodePudding user response:

A for loop has no problems writing those "special characters" with the for metavariable. And there is no need to 'dequote' or delayed expansion (for printing). And no need to escape the > with the preferred set syntax:

@echo off
setlocal enabledelayedexpansion 
set "en=>"
set rip=3
set "_in="
for /L %%i in (1,1,%rip%) do set "_in=!_in!%en%"
for /F %%a in ("%_in%") do echo %%a
pause

CodePudding user response:

Based on the comments on the VT100 escape sequences you're using, this should do what you want:

@echo Off
setlocal enabledelayedexpansion
for /F %%i in ('"echo prompt $E | cmd"') do set "ESC=%%i"
set "en=>" & set "rip=3" & set "_in="
for /L %%i In (1,1,%rip%) Do Set "_in=!_in!%en%"

set /p term=%ESC%[95m^!_in!%ESC%[0m
echo(!term!
  • Related