Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to echo "on" or "off" text only?

Everyone knows, that in Windows command file (.cmd)

echo on
echo off

enables and disables echo. But how to echo only text "on" or text "off"? I.e. how to send text

on
off

to stdout?
Target system: Windows XP.
And what about making it in DOS?

like image 728
green Avatar asked Jun 19 '16 20:06

green


People also ask

What does @echo off do?

The ECHO-ON and ECHO-OFF commands are used to enable and disable the echoing, or displaying on the screen, of characters entered at the keyboard. If echoing is disabled, input will not appear on the terminal screen as it is typed. By default, echoing is enabled.

How do I echo text in CMD?

To display the command prompt, type echo on. If used in a batch file, echo on and echo off don't affect the setting at the command prompt. To prevent echoing a particular command in a batch file, insert an @ sign in front of the command.

What does @echo off do in a batch file?

Example# @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

What does echo off mean in CMD?

That means that every command issued in a batch file (and all of its output) would be echoed to the screen. By issuing, the 'echo off' command, this feature is turned off but as a result of issuing that command, the command itself will still show up on the screen.


1 Answers

C:\> echo.on
on
C:\> echo.off
off

This actually works with a number of different characters, including but possibly not limited to:

/, \, ,, :, ;, (.

According to this thread on dostips.com, it's actually best (most robust) to use:

echo(on

As the other characters have obscure situations in which they can fail (e.g. a file named echo exists on %PATH%).

like image 146
Blorgbeard Avatar answered Sep 23 '22 15:09

Blorgbeard