Use of the echo command for DOS commands _dos/bat

Source: Internet
Author: User
Tags echo command
The echo command is a child command of a DOS batch command familiar to you, but some of its features and usage maybe you don't know all about it, you see:
1. Whether to display the command line itself at execution time as a control batch command
Format: ECHO [on| OFF]
If you want to turn off the display of the ECHO off command line itself, you need to precede the command line with "@".
2. Displays the current ECHO setting state
Format: ECHO
3. Output hint information
Format: Echo Information content
These are the three common uses of the echo command, which are familiar and available, but you should also know the following tips as a DOS command miner:
4. Turn off the DOS command prompt
Type echo off at the DOS prompt to turn off the display of the DOS prompt so that the screen leaves only the cursor until you type echo on and the prompt will appear again.
5. Output blank line, which is equivalent to entering a carriage return
Format: ECHO.
It is important to note that in the command line. "There must be no spaces in the middle of the echo, otherwise". "will be output to the screen as a cue message. In addition ". "may use,:;"/[\]+, such as any symbol substitution.
In the following example, Echo. The output carriage return, which is turned into a DOS pipe as input to the time command, is equivalent to giving a carriage return after the time command has been executed. Therefore, the system automatically returns to the DOS prompt after the current time is displayed:
c:>echo.| Time
The echo command outputs another application instance of a blank row: the echo. Add to the automatic batch file so that the cue screen originally displayed at the bottom of the screen appears above the screen.
6. Answer a question in a command
Format: Echo Reply | command file name
The above format can be used to simplify the operation of a number of man-machine conversation commands (such as: Chkdsk/f;format Drive:;del *.*), which is the input to the Man-machine conversation command using the preset reply of the echo command output via the DOS pipe command. The following example is equivalent to entering "Y" carriage return when the calling command has a man-machine conversation:
C:>echo y| chkdsk/f
C:>echo y| DEL A:*. *
7. Create a new file or increase the contents of a file
Format: ECHO file contents > filename
ECHO file content > > filename
For example: C:>echo @ECHO off>autoexec. BAT set up automatic batch processing file
C:>echo c:\cpav\bootsafe>>autoexec. BAT appends content to an automatic batch file
C:type AUTOEXEC. BAT displays the automatic batch file
@ECHO off
C:\CPAV\BOOTSAFE
8. Print output or print control code to the printer
Format: ECHO Printer control Code >PRN
ECHO Print Content >prn
The following example is the input print control code to the M-1724 printer. <Alt> 156 is to press the ALT key to type 156 on the keypad, and so on:
C:>echo <alt>+156<alt>+42<alt>+116>prn (Input underline command fs*t)
C:>echo <alt>+155@>prn (Input initialization command esc@)
C:&GT;ECHO.&GT;PRN (line Wrap)
9. To ring the horn.
C:>echo ^g
"^g" is input with ctrl+g or alt+007, input multiple ^g can produce multiple beeps. The use method is to add it directly to a batch file or to make a batch file call.
10. To perform the ESC control sequence to modify screen and keyboard settings
We know that the DOS device driver Ansi.sys provides a set of ESC control sequences to modify the screen and keyboard settings. A batch program that performs the following can define the function key F12 as a DOS command "dir/w" and modify the screen color to a white character blue background.
@ECHO "←[0;134;" Dir/w "; 13p
@ECHO "←[1;37;44m
(Note: the "←" character input method in the batch file is to press ALT on 27 on the keyboard in edit state)
DOS commands are the first thing a person in touch with a computer learns, for many people is too familiar too simple, but in fact, in these commands contain a wealth of content, still waiting for us to further understand to develop, if you are a conscientious person will certainly from these think familiar commands found new sparkle, Amoy gold.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.