The usage of ECHO in Linux __linux

Source: Internet
Author: User
Tags echo command echo message

The echo command of Linux, which is very commonly used in shell programming, is often used when printing variable value under a terminal, so it is necessary to understand the use of the following Echo

The function of the echo command is to display a piece of text on the monitor, which generally acts as a hint.
The general format for this command is: Echo [-n] String
where option n means that the output text does not wrap, and the string can be enclosed in quotes or without quotes. Output a quoted string with the Echo command, outputting the string as it is, and using the echo command to output a string without quotes, each word in the string is output as a string, separated by a space between the strings.

Function Description: Display text.
Syntax: Echo [-ne][string] or echo [--help][--version]
Supplemental Note: Echo will send the input string to standard output. The output string is separated by a white space character and the last line number is added.
Parameters:-n do not wrap at the last line
-E If the following characters appear in the string, it is handled in particular, not as a general
Text output:
\a issued a warning sound;
\b Deletes the previous character;
\c finally does not add line symbol;
\f the line but the cursor still stays in the original position;
\ n Wraps and the cursor moves to the beginning of the line;
\ r The cursor moves to the beginning of the line, but does not wrap;
\ t Insert tab;
\v and \f are the same;
\ \ insert \ character;
\NNN inserts the ASCII character represented by the NNN (octal);
–HELP Display Help
–version Display version Information

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. The switch format in which the command line itself is displayed as a control batch command at execution time: 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 settings status format: Echo

3. Output hint Information format: Echo message content The above are three common uses of the echo command and are familiar and available, but as a DOS command miner you should also know the following tips:

4. Turn off the DOS command prompt by typing echo off at a DOS prompt, you can 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.| The time 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. Question format in reply to command: Echo Reply | command file name the above format can be used to simplify some of the commands that require man-machine conversation (such as: Chkdsk/f;format Drive:;del *.*) operations, It is the input to the Man-machine conversation command using the preset reply of the echo command output through the DOS pipe command. The following example is equivalent to entering "Y" carriage return when the calling command appears in Man-machine conversation: C:〉echo y| chkdsk/f C:〉echo y| DEL A:*. *

7. Create a new file or add a file content format: Echo file contents > filename echo file content-filename For example: C:〉echo @ECHO off〉autoexec. BAT establishes an automatic batch processing file C:〉echo c:/cpav/bootsafe〉〉autoexec. BAT appends content C:type AUTOEXEC to an automatic batch file. BAT displays the automatic batch file @ECHO off C:/cpav/bootsafe

8. Output print to the printer or print control code format: Echo Printer control code >prn echo Print content >prn The following example is to enter the print control code to the M-1724 printer. 156 is to hold down the ALT key to type 156 in the keypad, and so on: c:〉echo〈alt〉+156〈alt〉+42〈alt〉+116〉prn (Enter underline command fs*t) c:〉echo〈alt〉+155@〉 PRN (Input Initialization command esc@) c:〉echo.〉prn (newline)

9. Make the Horn sound 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. Perform ESC control sequence modify screen and keyboard settings we know that DOS device driver Ansi.sys provides a set of ESC control sequences to modify 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.

                                               ----reprinted from http://www.cnblogs.com/ZhangShuo/articles/ 1829589.html

Related Article

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.