Table of Contents

Dos - Echo

About

Displays messages, or turns command-echoing on or off.

If you use special character, don't forget to escape them.

How to

echo a blank line

Just add the special characters bracket or period just after the echo command

echo[
echo.

echo in red or green color

You can echo in color with color terminal escape sequence

for /F %%a in ('"prompt $E$S & echo on & for %%b in (1) do rem"') do set "ESC=%%a"

then use it to create a control sequence

set TEXT=text to print
REM green
echo %ESC%[32m%TEXT %ESC%[0m
REM red
echo %ESC%[32m%TEXT %ESC%[0m

More color see batch_colors.cmd

Syntax

Display Messages

echo my beautiful message
my beautiful message

Configuration

Syntax

Turns command echoing on or off

ECHO [ON | OFF]

where:

You don't turn on or off the echo function, you turn on or off the echoing of the command.

The Rem command is never echoed

Example

echo my Echo
> echo my Echo 
my Echo

echo off
echo my Echo
>echo off 
my Echo

@echo off
echo my Echo
my Echo

Special Character

At

If a line is prefixed by the special character “@”, the block command will not be echoed to standard output (if echo is turned on) but

an echo message will

Example:

for %%v in (*.*) do (echo %%v)
>for %v in (*.*) do (echo %v ) 
>(echo my.bat ) 
my.bat
>(echo test.bat ) 
test.bat

for %%v in (*.*) do @(echo %%v)
>for %v in (*.*) do @(echo %v ) 
my.bat
test.bat

@for %%v in (*.*) do @(echo %%v)
my.bat
test.bat

@echo off
for %%v in (*.*) do (echo %%v)
my.bat
test.bat