The echo command in Windows

The echo command displays the message or turns on / off the command repeat feature. If used without parameters, the echo command will display the current echo setting.

The echo command displays the message or turns on / off the command repeat feature. If used without parameters, the echo command will display the current echo setting.

For an example of how to use this command, please see the example below.

Syntax echo command

 echo [] echo [on | off] 

Parameters

ParameterDescription [on | off] Enable or disable the repeat command feature. The repeat command is turned on by default. Specify text displayed on the screen. /? Show help at the command prompt.

Note

  1. The Message echo is particularly useful when echo is disabled. To display a message that is only a few lines long without displaying any commands, you can include several echo messages after the command echo off in the batch program.
  2. When echo is disabled, the command prompt will not appear in the Command Prompt window. To display the command prompt, enter echo on.
  3. If used in a batch file, echo on and echo off does not affect the settings at the command prompt.
  4. To prevent repeating a specific command in a batch file, insert a (@) sign in front of the command.To prevent repeating all commands in a batch file, include the echo off command at the beginning of the file.
  5. To display the character (|) or navigation character () when you are using the echo command , use a caret (^) immediately before the straightforward character or redirect (eg: ^ | , ^> or ^ <).To display the caret, enter two consecutive quotes (^^).

For example

To display the current echo installation, enter:

 echo 

To loop a blank line on the screen, enter:

 echo. 
Note:

Do not include spaces before the dot. Otherwise, the dot will be displayed instead of a blank line.

To prevent repeat commands at the command prompt, type:
 echo off 

Note :

When the echo command is turned off, the command prompt will not appear in the Command Prompt window. To display the command prompt again, type echo on.

To prevent all commands in a batch file (including the echo off command) displayed on the screen, on the first line of the batch file, enter:

 @echo off 

You can use the echo command as part of an if statement. For example, to search for the current directory for any file with the .rpt file name extension and to repeat the message if you find such a file, enter:

 if exist *.rpt echo The report has arrived. 

The following batch file is searched in the current directory where the file has a file name extension of .txt and displays a message indicating the search results:

 @echo off if not exist *.txt ( echo This directory contains no text files. ) else ( echo This directory contains the following text files: echo. dir /b *.txt ) 

If the .txt file cannot be found when the batch file is run, the following message will appear:

 This directory contains no text files. 

If the .txt file is found when the batch file is run, the following output is displayed (this example, assuming files File.txt, File2.txt and File3.txt exist):

 This directory contains the following text files: File1.txt File2.txt File3.txt 

See more:

  1. Dcgpofix command in Windows
  2. Driverquery command in Windows
  3. The certutil command in Windows
4.7 ★ | 3 Vote