Showing posts with label ECHO. Show all posts
Showing posts with label ECHO. Show all posts

Tuesday, 26 May 2015

ECHO in a Command Prompt

Contents:

Introduction

As per the DOS shell, the ECHO command brings up the following when you type HELP ECHO

C:\>help 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.

Open a new Command prompt window and try the following:

ECHO without parameters

C:\>echo
ECHO is on.

ECHO [ON | OFF]

To turn Echo Off, try the below
C:\>echo off
_
You would notice that the prompt with the current path has now disappeared. Test the setting by typing in echo and press Enter. You would see the below:
 
echo
ECHO is off.

To turn Echo off, type the below and press Enter. You should now see your prompt with the current path being displayed:

echo on
C:/>

ECHO [message]

  • ECHO Static String

On the command prompt, try the below:
C:\>echo Hello World
Hello World

C:\>echo "Hello World"
"Hello World"

C:\>echo 'Hello World'
'Hello World'


In short, anything that follows the Echo will be displayed. You dont have to quote it. If you add quotes, you notice that the quotes themselves are also displayed.
  • ECHO with Variables

If your using variables, which you might do in a Command Prompt, then the below is useful

C:\>set STRING="HELLO WORLD"
C:\>echo %STRING%
"HELLO WORLD"

If your using Environment Variables for instance:
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_45