Guides:Shells/COMMAND.COM-CMD.EXE/DOS Commands/ECHO

From CoderGuide

Jump to: navigation, search

Return to: Guides:Shells/COMMAND.COM-CMD.EXE/DOS Commands

ECHO

Format:

ECHO text to print
ECHO off|on
ECHO
ECHO. (DOS 5.0+)


ECHO does a few things in MS-DOS.

  • Prints out a line of text
  • Suppresses the printing of the commands in a batch file
  • Displays the current echo status.

If you merely typed ECHO at the command prompt, all you'd normally see is "ECHO is on." You can change the ECHO to OFF if you wish by typing "ECHO off"

C>'''ECHO'''
ECHO is on
C>'''b.bat'''
C>echo Hello World
Hello World
C>'''ECHO OFF'''
'''b.bat'''
Hello World
'''echo on'''
C>

Most batch files begin with echo off. To avoid even the statement "echo off" from being displayed, they would use @echo off. The @ character tells DOS not to print that one line.

To get a blank line, batch file writers would often use a trick. They would tell ECHO to print another blank (in the IBM character set) ASCII character 255. To enter in this character, hold down the ALT key, and, on the number pad (MUST be the number pad), punch in 255, and release the alt key. This doesn't work as well in Windows (at least when not in full screen mode) as it does with a command prompt.

DOS 5.0 introduced "ECHO." (ECHO with a sigle period at the end)which allows printing of blank lines without having to type in the magic key combination mentioned above.

The Unix echo doesn't have this problem. If you want a blank line, just type "echo" by itself. Unix shell scripts don't echo the commands they are executing, so the idea of needing to specify echo on or echo off' is silly.

Personal tools