green
green

Reputation: 345

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?

Upvotes: 7

Views: 689

Answers (1)

Blorgbeard
Blorgbeard

Reputation: 103467

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%).

Upvotes: 8

Related Questions