China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 13:52
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Usage of the ECHO Command in DOS Commands View 4,268 Replies 21
Original Poster Posted 2008-12-25 12:39 ·  中国 江苏 常州 电信
新手上路
Credits 7
Posts 4
Joined 2008-11-23 12:09
17-year member
UID 131829
Gender Male
Status Offline
Usage of the ECHO Command in DOS Commands

The ECHO command is a sub - command of the DOS batch processing commands that everyone is familiar with, but some of its functions and usages may not all be known to you. Just take a look:

1. As a switch to control whether the command line itself is displayed when the batch processing command is executed
Format: ECHO
If you want to close the display of the "ECHO OFF" command line itself, you need to add "@" before this command line.

2. Display the current ECHO setting status
Format: ECHO

3. Output prompt information
Format: ECHO information content

The above are the three common usages of the ECHO command, and they are also what everyone is familiar with and can use. But as a gold digger of DOS commands, you should also know the following skills:

4. Turn off the DOS command prompt
Typing ECHO OFF in the DOS prompt state can turn off the display of the DOS prompt, leaving only the cursor on the screen. The prompt will reappear until ECHO ON is typed.

5. Output a blank line, which is equivalent to entering a carriage return
Format: ECHO.
It should be noted that the "." in the command line should be immediately after ECHO without a space in between, otherwise the "." will be regarded as prompt information and output to the screen. In addition, the "." can be replaced by any one of symbols such as,,:;"/+.
In the following example, the carriage return output by ECHO. is transferred through the DOS pipe as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executing, the system will automatically return to the DOS prompt state after displaying the current time:
C:>ECHO.|TIME
Another application example of the ECHO command outputting a blank line is: adding ECHO. in the auto - batch file, so that the originally displayed prompt screen at the bottom of the screen appears at the top of the screen.

6. Answer the question in the command
Format: ECHO answer|command filename
The above format can be used to simplify the operation of some commands that need man - machine dialogue (such as CHKDSK/F; FORMAT Drive:; del *.*). It is to use the DOS pipe command to take the preset answer output by the ECHO command as the input of the man - machine dialogue command. The following example is equivalent to entering "Y" and pressing the carriage return when the called command has a man - machine dialogue:
C:>ECHO Y|CHKDSK/F
C:>ECHO Y|DEL A :*.*

7. Create a new file or add content to a file
Format: ECHO file content>filename
ECHO file content>>filename
For example: C:>ECHO @ECHO OFF>AUTOEXEC.BAT to create an auto - batch file
C:>ECHO C:\CPAV\BOOTSAFE>>AUTOEXEC.BAT to append content to the auto - batch file
C:TYPE AUTOEXEC.BAT to display the auto - batch file
@ECHO OFF
C:\CPAV\BOOTSAFE

8. Output print content or print control codes to the printer
Format: ECHO printer control code>PRN
ECHO print content>PRN
The following example is to input print control codes to the M - 1724 printer. <Alt>156 is pressing the Alt key and typing 156 on the numeric keypad. The same situation can be deduced by analogy:
C:>ECHO <Alt>+156<Alt>+42<Alt>+116>PRN (input the underline command FS*t)
C:>ECHO <Alt>+155@>PRN (input the initialization command ESC@)
C:>ECHO.>PRN (new line)

9. Make the speaker beep
C:>ECHO ^G
"^G" is input by Ctrl+G or Alt+007. Entering multiple ^G can produce multiple beeps. The usage is to directly add it to the batch file or make a batch file to call.

10. Execute the ESC control sequence to modify the screen and keyboard settings
We know that the device driver ANSI.SYS of DOS provides a set of ESC control sequences for modifying screen and keyboard settings. For example, executing the batch program with the following content can define the function key F12 as the DOS command "DIR/W" and modify the screen color to white characters on a blue background.
@ECHO"←






———————————————
Transferred from Feedback & User Communication
Obviously posted in the wrong section, deduction for points is processed
——Administrator
———————————————
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
DOSroot -2 2008-12-25 18:19
Floor 2 Posted 2008-12-25 12:49 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Please post in the appropriate section, will you?
Floor 3 Posted 2009-01-10 15:05 ·  中国 广东 清远 清城区 电信
新手上路
Credits 10
Posts 5
Joined 2009-01-10 02:45
17-year member
UID 136280
Gender Male
Status Offline
Hope the original poster will make persistent efforts
Floor 4 Posted 2009-01-14 02:04 ·  中国 云南 昆明 电信
初级用户
Credits 20
Posts 13
Joined 2008-09-21 05:13
17-year member
UID 126185
Gender Male
Status Offline
Learned it, didn't expect echo has so many tricks, thanks for sharing~~
Floor 5 Posted 2009-01-28 13:55 ·  中国 四川 绵阳 电信
初级用户
Credits 46
Posts 23
Joined 2009-01-28 01:32
17-year member
UID 137519
Gender Male
Status Offline
I'll take this. There are actually so many uses. I only knew it was used to turn off command line echoing before. Learned something new today. Thanks to the楼主~
Floor 6 Posted 2009-01-29 15:17 ·  中国 四川 宜宾 联通
初级用户
Credits 56
Posts 40
Joined 2009-01-23 23:49
17-year member
UID 137337
Gender Male
Status Offline
Floor 7 Posted 2009-03-07 12:42 ·  中国 湖南 常德 电信
初级用户
Credits 42
Posts 27
Joined 2009-02-24 16:42
17-year member
UID 139744
Gender Male
Status Offline
Learning
Floor 8 Posted 2009-10-07 13:04 ·  中国 江苏 南京 电信
初级用户
★★
Credits 62
Posts 62
Joined 2007-07-14 14:39
19-year member
UID 93962
Gender Male
Status Offline
Alas, I've been studying for a long time, but I still have to start from the basics. Thanks to the楼主.
Floor 9 Posted 2009-10-09 20:45 ·  中国 天津 电信
新手上路
Credits 8
Posts 4
Joined 2009-10-07 19:41
16-year member
UID 152730
Gender Male
Status Offline
What seems simple on the surface is actually quite complicated.
Floor 10 Posted 2009-10-10 23:18 ·  中国 陕西 西安 电信
初级用户
Credits 23
Posts 12
Joined 2009-02-13 06:48
17-year member
UID 138717
Gender Male
Status Offline
Oh, I'm so surprised. The echo command can be used like this. Haha, I've gained new knowledge.
Floor 11 Posted 2009-10-11 11:27 ·  中国 广东 深圳 龙岗区 电信
初级用户
开心小子
Credits 59
Posts 29
Joined 2009-05-06 01:28
17-year member
UID 144451
Gender Male
From 广东
Status Offline
If every command I get is like this in detail... It will definitely improve a lot at once.
开心最好!
快乐你我!
Floor 12 Posted 2009-11-16 18:27 ·  中国 天津 联通
新手上路
Credits 7
Posts 5
Joined 2009-01-08 18:18
17-year member
UID 136150
Gender Male
Status Offline
Learning, in the process of learning, great stuff!
Floor 13 Posted 2009-11-17 22:05 ·  中国 安徽 合肥 移动
新手上路
Credits 14
Posts 7
Joined 2009-10-04 11:07
16-year member
UID 152598
Gender Male
Status Offline
Learned, and also learned other usages of the echo command.
Floor 14 Posted 2009-11-19 15:44 ·  中国 江苏 淮安 电信
新手上路
Credits 4
Posts 2
Joined 2009-11-17 13:36
16-year member
UID 154873
Gender Male
Status Offline
Learn and learn. Hehe, I still don't understand anything yet
Floor 15 Posted 2009-11-19 18:31 ·  中国 四川 成都 电信
新手上路
Credits 15
Posts 12
Joined 2008-12-01 09:53
17-year member
UID 132541
Gender Male
Status Offline
Come in with the attitude of learning...
Forum Jump: