Command: echo (command.com command)

  ECHO displays messages, or turns command-echoing on or off.
  There also exists a CONFIG.SYS / FDCONFIG.SYS ECHO command.
  ECHO is a BATCH-FILE / AUTOEXEC.BAT / FDAUTO.BAT command.
  It can also be used in command line (except with @ - at symbol).

Syntax:

  1. ECHO [ON | OFF]
  2. ECHO [message (string)]
  3. ECHO.

Options:

  ON       ECHO mode is activated. If you use ECHO within a batch
           file, each command line is shown when it is executed.
  OFF      ECHO mode is deactivated. If you use ECHO within a batch
           file, the command line is not shown when it is executed.
           This does not affect the output of the command itself.
  message  The message you want to print on the screen.
  .        Displays an empty line.
  /?       Shows the help.

Comments:

  When executing a BATCH script each line is displayed to the console
  before executing it by default. The first variant of ECHO enables or
  disables this behaviour. To disable echoing the command is equal to
  prefix each line of a batch script with the at-symbol @.
  If ECHO is invoked with no argument at all, the current echo status
  is displayed.
  When entered on an interactive command line the echo status controls
  whether or not the PROMPT string is displayed.
  The second variant displays the specified "string". Note:
  Because of variant 1 "string" may not expand to the single words ON
  or OFF without another character.
  The third variant displays an empty line. No space must be placed
  between the dot and ECHO.
  ECHO can be used to create text files, e.g. BATCH files. In this case
  you have to send the text to a file via ">" or ">>" if you
  want to add several lines. See example below. % characters have
  to be added twice.
  As ">", "<", and | are in use by ECHO they can only be used
  in an ECHO text when you put them into quotation marks or you put a
  caret character in front of them.
  ECHO is a command internal to command.com and needs no other file
  in order to work. There also exists a CONFIG.SYS / FDCONFIG.SYS
  ECHO command with different options.

Examples:

  Example 1 (in command line and BATCH):
    ECHO
  Displays the current echo status, e.g. responding:
    ECHO is on

  Example 2 (only in a BATCH file):
    @ECHO OFF
  Disables the echo status. Because the at-sign @ disables the echo
  status right for this line, this command disable echoing all the next
  lines of a batch script and is not echoed to the console itself. It
  is, therefore, best placed in the first line of a batch script.

  Example 3 (in command line and BATCH):
    ECHO Just a text
  Displays Just a text

  Example 4:
  IN A BATCH FILE / AUTOEXEC.BAT:
    ECHO Hi,            (As ECHO is not switched off, command + execution
                        (text: "Hi,") is shown)
    @ECHO Hi,           (@ character prevents showing command, only
                        text: "Hi,")
    ECHO How are you?   (As ECHO is not switched off, command + execution
                        (text: "How are you" is shown)
    @ECHO How are you?  (@ character prevents showing command, only
                        text: How are you?)
    ECHO.               (As ECHO is not switched off, command + execution
                        ("empty line"') is shown)
    @ECHO.              (@ character prevents showing command, only
                        "empty line" is shown)
    @ECHO off           Switches off echoing in the following lines:
    ECHO Fine?          Shows "Fine?"only
    @ECHO Fine?         Shows "Fine?" only
    ECHO.               Shows "empty line" only
    @ECHO.              Shows "empty line" only
    @ECHO Great!        Shows "Great!" only
    ECHO on             Switches ECHO on again

  Example 5:
  You want to create a text file with ECHO:
    ECHO How are you? > C:\DOCUMENT\areyouok.txt
    ECHO Yes, I am fine >> C:\DOCUMENT\areyouok.txt
    ECHO At least for 50 %% >> C:\areyouok.txt

  Example 6:
  You want to write a text with special characters that cannot be used
  directly, e.g. < > | %:
    set var=FreeDOS
    (TEXT: I use < > | % %var%)
    @ECHO "I use < > | %% %var%"   shows: "I use < > | % FreeDOS"
    @ECHO I use ^< ^> ^| %% %var%  shows: "I use < > | % FreeDOS"

  Example 7:
    echo Hallo Welt | sed -e "s/a/e/" -e "s/Welt/world/"
    Result: Hello world (replaces a by e and Welt by world.

See also:

  @ (at)
  autoexec.bat/fdauto.bat
  batch files
  command.com/freecom
  echo (config.sys command)
  gnused/sed

  Copyright © 2004 Robert Platt, updated 2011 and 2022 by W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.