Prints its own arguments back out to the DOS equivalent of the standard output stream. Usually, this means directly to the screen, but the output of echo can be redirected like any other command. Often used in batch files to print text out to the user. | ||||
SYNTAX: | ||||
|
||||
Another important use of the echo command is to toggle echoing of commands on and off in batch files. | ||||
|
||||
Traditionally batch files begin with the @echo off statement. This says to the interpreter that echoing of commands should be off during the whole execution of the batch file thus resulting in a “tidier” output. The @ symbol declares that this particular command (echo off) should also be executed without echo. | ||||
For example the following 2 batch files are equivalent: | ||||
Batch1.bat: | ||||
@echo off echo The files in your root directory: dir /b /a-d c:\ |
||||
Batch2.bat: | ||||
@echo The files in your root directory: @dir /b /a-d c:\ |
||||
Echo can be used to write to files directly from the console, by redirecting the output stream: | ||||
echo text > filename | ||||
Echo can also be used to append to files directly from the console, again by redirecting the output stream: | ||||
echo text >> filename | ||||
To type more than one line from the console into a file, use copy con (above). |