Cu Play Shell 13 question: How much is echo

xiaoxiao2021-03-06  63

Author: human network

Undertake the Command Line described in the previous chapter, here we use the Echo this command to further explain. Templer --- Standard Command Line contains three parts: * Command_name Option Argument Echo is a very simple, direct Linux command: * Send Argument to standard output (stdout), usually output on the Monitor). (Note: Stdout will have the opportunity to explain again, or you can first refer to the following discussion:

http://www.chinaunix.net/forum/viewtopic.php?t=191375

In order to better understand, let us first run the echo command:

Code: $ Echo $

You will find that there is only one blank row, then return to the shell prompt. This is because Echo is in the preset, and after the Argument is displayed, a new-line character will be sent. But the above Command does not have any argument, then only one wrap symbol is left ... If you want to cancel this wrap symbol, you can take advantage of ECHO -n Option:

Code: $ echo -n $

Let us return to the concept of Command Line to discuss the Echo command in the previous example: * Command Line is only Command_Name (Echo) and Option (-N) and does not have any argument. If you want to see the Echo's Argument, it is not easy! Next, try the following input:

Code: $ Echo First Line First Line $ Echo -n First Line First Line $

In the two Echo commands, you will find that the Argument part is displayed on your screen, and the wrap symbol is the case-N Option. Obviously, the second echo is canceled because the wrap symbol is canceled, the next shell prompt is connected to the output result in the same line ... ^ _ ^ In fact, Echo except -n Options, the common option is also: -e: Enable the conversion of a backslash control character (refer to the following table) -e: Turn off the conversion of the anti-reselling control character (Preset) -N: Cancel the line transfer symbol (with the / c character under the -e option) The anti-laminated line control character supported by the echo command is as follows: / A: Alert / Bell (from the system speaker) / B: backspace, that is, to the left delete button / c: Cancel the line of wrap symbol / E: escape, Jumping keeper / f: formfeed, change page character / N: newline, wrap character / r: return, Enter key / T: Tab, Table Tab / V: Vertical Tab, Vertical Table Jump button / N: ASCII Eight Carrying the encoding (with X-6) //: The anti-sliding line itself (Table information from the Learning the Bash Shell, 2nd Ed.) Of O'Reilly Press, we can learn about Echo's options and control through an instance. Character: Example:

Code: $ Echo -e "A / TB / TC / ND / TE / TF" A b C D e f

The above example uses / t to distinguish ABC and DEF, and use / n to change the DEF to the next row. Example 2:

Code: $ Echo -e "/ 143/012/144/011/145/011/146" A b C D e f

As with the results of an example, just use the ASCII eight-in-line encoding. Example 3:

Code: $ echo -e "/ x61 / x09 / x62 / x09 / x63 / x0a / x64 / x09 / x65 / x09 / x66" A b C D e f

There are many differences from the example, just this time you exchange ASCII hex. Example 4:

Code: $ Echo -ne "A / TB / TC / ND / TE / BF / A" A B C D f $

Because the e-letter is the delete key (/ b), there is no E for the output result. I heard a bell at the end, that is the masterpiece of / A! Since the -n option is used at the same time, shell PROMPT is next after the second line. If you don't have to -n, then you add a / c after / a, and the same effect. In fact, in the future shell operation and shell script design, the echo command is one of the most commonly used commands. For example, use ECHO to check the variable:

Code: $ a = b $ Echo $ A b $ echo $? 0

(Note: About variable concept, we have left to the next chapter to explain it with you.) Ok, more about the format of Command Line, and the options for the echo command, please practice more, apply ...

转载请注明原文地址:https://www.9cbs.com/read-90359.html

New Post(0)