Dos - Echo

Card Puncher Data Processing

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:

  • ON is the default

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

  • With the following bat, echo is by default on
echo my Echo
  • By starting it, you get
> echo my Echo 
my Echo

  • By echoing off, you will get
echo off
echo my Echo
>echo off 
my Echo

  • To suppress the echoing of the echo off, use the section special character
@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:

  • the following bat file will list the content of a directory (test.bat and my.bat)
for %%v in (*.*) do (echo %%v)
>for %v in (*.*) do (echo %v ) 
>(echo my.bat ) 
my.bat
>(echo test.bat ) 
test.bat

  • If you don't want to see the (echo …) message, change your file as below:
for %%v in (*.*) do @(echo %%v)
>for %v in (*.*) do @(echo %v ) 
my.bat
test.bat

  • and if you don't want to see the for statement,
@for %%v in (*.*) do @(echo %%v)
my.bat
test.bat

  • of course, you can turn off globally (and then not by block command)
@echo off
for %%v in (*.*) do (echo %%v)
my.bat
test.bat





Discover More
Card Puncher Data Processing
DOS - (Control Operators | Command Separator)

Dos supports the following control operator in order to control or separate command instruction. Operator Description & all commands run serially without error checking && execute the next command...
Card Puncher Data Processing
DOS - Special Characters

This article tries to list all special characters and their meanings. Character Description Articles | pipeline > stdout < stdin 2> stderr >> append & duplicate handle or control...
Card Puncher Data Processing
Dos - (Batch) Script

The batch script is a text file with the extension .bat or .cmd that is interpreted by a batch interpreter. You can call a batch script by : writing its name in the source script: The script execution...
Card Puncher Data Processing
Dos - Cmd (Command interpreter)

Cmd starts a new instance of the Windows command interpreter More info: The switches must be on one line but for the purpose of clarity we have put one switch by line. where: /Q turns echo off...
Card Puncher Data Processing
Dos - Command

A command is: a Dos command (See below). of an utility. The DOS command are extended with management tools located in C:\Windows\System32...
Card Puncher Data Processing
Dos - Escape Character

To escape a special character, you use: % for a % " for a " Otherwise ^ With echo
Java Conceptuel Diagram
Java - (Jar|Java ARchive) File

JAR stands for Java ARchive and is file format born in 1996 as a simple extension of the popular ZIP archive format with class and other required resource files: manifest signature files images,...
Windows Powershell Menu
PowerShell - Out-Null (echo off, /dev/null)

To discard the output of a command, you don't set the echo to off as in DOS but you send it to Out-Null same as /dev/null on Linux ...
Card Puncher Data Processing
Shell Data Processing - Echo

Echo is a command that accepts an argument as standard input, and echoes it back to the terminal as standard output.
Card Puncher Data Processing
Shell Data Processing - Echo (Gnu Utility)

This page is the echo executable of the Gnu utility package that implements an echo functionality. echo To echo a string: where: -n: do not output a newline character. See the example...



Share this page:
Follow us:
Task Runner