ECHO
suggest changeDisplays messages, or turns command echoing on or off.
Examples:
echo on@echo offecho Helloecho "hello"Displays the quotes too.
echo %PATH%Displays the contents of
PATHvariable.echo Owner ^& sonUses caret (
^) to escape ampersand (&), thereby enabling echoing ampersands.echo 1&echo 2&echo 3Displays three strings, each followed by a newline.
echo.Outputs a newline while the period is not being output. Without the period, outputs
echo offorecho on. Adding a space before the period leads to the period being output. Other characters having the same effect as period include:;,/\(=+[].echo %random%>>MyRandomNumbers.txtWhile it seems to output random numbers to
MyRandomNumbers.txt, it actually does not do so for numbers 0-9, since these, when placed before>>, indicate which channel is to be redirected. See also redirection.echo 2>>MyRandomNumbers.txtInstead of echoing 2, redirects standard error to the file.
(echo 2)>>MyRandomNumbers.txtEchoes even a small number (in this case 2) and redirects the result.
>>MyRandomNumbers.txt echo 2Another way to echo even a small number and redirect the result.
Displaying a string without a newline requires a trick:
set <NUL /p=Output of a command:Displays "Output of a command:". The output of the next command will be displayed immediately after
:.set <NUL /p=Current time: & time /tDisplays "Current time: " followed by the output of
time /t.(set <NUL /p=Current time: & time /t) >tmp.txtLike before, with redirecting the output of both commands to a file.
Links:
$ echo /?
Displays messages, or turns command-echoing on or off.
ECHO [ON | OFF]
ECHO [message]
Type ECHO without parameters to display the current echo setting.