如何用命令ECHO输出多个大于号>(右尖括号)?

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

在这种情况下,我想输出 >>>echo。但是先有输出:

Press any key to continue . . .

按下一个键后接下来输出:

> was unexpected at this time.

有什么办法可以解决吗?

批处理文件是:

@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

A​​ for 循环在使用 for 元变量写入那些“特殊字符”时没有问题。并且不需要 'dequote' 或延迟扩展(用于打印)。无需使用首选 set 语法转义 >

@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

按照你的方式去做,它会更像这样:

@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

根据对您使用的 VT100 转义序列的评论,这应该可以满足您的要求:

@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!