Summary of the use of Echo under Linux

Source: Internet
Author: User
Tags clear screen echo command

First, the use of the echo command

Description: Echo will send the input string to standard output. The output strings are separated by white space characters, and a newline number is added at the end.

Function: Display characters

Syntax: Echo [-nee] [string]

The echo command common options Description:

1,-N: no automatic line wrapping

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/98/wKioL1eVvdeQ-FPIAAAmEWIJXOs883.png "title=" 1.png " alt= "Wkiol1evvdeq-fpiaaamewijxos883.png"/>


2,-e: Usually combined with the escape character "\" to use, so that the escape character (if the following characters appear in the string, it is handled in particular, but not as a general text output)


\a issued a warning sound

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/84/98/wKioL1eVvhzClDFMAAAWvcbdwaY836.png "title="-a.png "alt=" Wkiol1evvhzcldfmaaawvcbdway836.png "/>


\b Delete the previous character

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/84/98/wKioL1eVvjWB5Uy3AAAUqowZuQk737.png "title="-b.png "alt=" Wkiol1evvjwb5uy3aaauqowzuqk737.png "/>


\c suppresses the characters following the output and does not wrap automatically

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/98/wKiom1eVvlbykqltAAATX4ahw2E701.png "title="-c.png "alt=" Wkiom1evvlbykqltaaatx4ahw2e701.png "/>


\e Delete a character after

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/84/98/wKioL1eVvoWhpyi-AAAV0YF9vGU821.png "title="-e.png "alt=" Wkiol1evvowhpyi-aaav0yf9vgu821.png "/>


\ n Force line break

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/84/98/wKioL1eVvqOwuZ7jAAAV9ff9VhE847.png "title="-n.png "alt=" Wkiol1evvqowuz7jaaav9ff9vhe847.png "/>


\ r The cursor moves to the beginning of a line, but does not wrap, overwriting the character at the beginning of the line

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/84/98/wKiom1eVvtDCwBIaAAAUZtbqfCY749.png "title="-r.png "alt=" Wkiom1evvtdcwbiaaaauztbqfcy749.png "/>


\ t inserts a horizontal tab

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/84/98/wKioL1eVvzHQ3Vc4AAAT4YaMSi8117.png "title="-t.png "alt=" Wkiol1evvzhq3vc4aaat4yamsi8117.png "/>


\v Inserting vertical Tabs

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/84/98/wKioL1eVv0nxFNJEAAAXSMi_2sY894.png "title="-v.png "alt=" Wkiol1evv0nxfnjeaaaxsmi_2sy894.png "/>


\ \ insert \ Symbol

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/84/98/wKioL1eVv2Lx00teAAAW_JqD5nA197.png "title="--. png "alt=" Wkiol1evv2lx00teaaaw_jqd5na197.png "/>


3.-E: Escape character with backslash disabled (default)

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/98/wKiom1eVv4PTLnCvAAAWDRKKKS8641.png "title=" 3.png " alt= "Wkiom1evv4ptlncvaaawdrkkks8641.png"/>


4. Output of variable value, usage: Echo $ variable Name

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/84/98/wKioL1eVv5WBqJ_GAAATosQ6W9s578.png "title=" 4.png " alt= "Wkiol1evv5wbqj_gaaatosq6w9s578.png"/>


5, double quotation marks: Indicates weak references, variables are replaced

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/84/98/wKioL1eVv77ih5O4AAATPaFrZqk729.png "title=" 5.png " alt= "Wkiol1evv77ih5o4aaatpafrzqk729.png"/>


6. Single quotes: denotes strong references, and variables are not replaced

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/84/98/wKioL1eVv9vgESkiAAAL4ZT_tig225.png "title=" 6.png " alt= "Wkiol1evv9vgeskiaaal4zt_tig225.png"/>

Second, echo output the content of the specified color

1, usage: Need to combine the-e option and "\033" piece to use

Format: echo–e "\033[foreground color; background color m string \033[0m"

Note: The foreground color and background color position can be interchanged

Foreground color: 30m-37m

Black: echo-e "\033[30m black character \033[0m"

Red: echo-e "\033[31m red word \033[0m"

Green: echo-e "\033[32m green word \033[0m"

Yellow: echo-e "\033[33m yellow word \033[0m"

Blue: echo-e "\033[34m blue word \033[0m"

Purple: Echo-e "\033[35m purple word \033[0m"

Sky blue: Echo-e "\033[36m sky blue Word \033[0m"

White: echo-e "\033[37m white character \033[0m"

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/84/98/wKioL1eVwALj356HAAA57p17Cws743.png "title=" 21.png "alt=" Wkiol1evwalj356haaa57p17cws743.png "/>


Background color: 40m-47m

Black: Echo-e "\033[40m Black Bottom \033[0m"

Red: echo-e "\033[41m Red Bottom \033[0m"

Green: Echo-e "\033[42m Green Bottom \033[0m"

Yellow: echo-e "\033[43m Yellow Bottom \033[0m"

Blue: echo-e "\033[44m Blue Bottom \033[0m"

Purple: Echo-e "\033[45m Purple Bottom \033[0m"

Sky blue: Echo-e "\033[46m sky blue Bottom \033[0m"

White: echo-e "\033[47m White Bottom \033[0m"

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/84/98/wKioL1eVwBvTsrp5AABBRB5eXLU588.png "title=" 22.png "alt=" Wkiol1evwbvtsrp5aabbrb5exlu588.png "/>


Example: The output of the yellow-bottom red Word display echo-e "\033[31;43m aaaaaaaaaaaa \033[0m"

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/84/98/wKiom1eVwDij1MWRAAAQzKQe_Vg388.png "title=" 23.png "alt=" Wkiom1evwdij1mwraaaqzkqe_vg388.png "/>


2. Control option Description

\033[0m Close All Properties

\033[1m Setting High brightness

\033[4m Underline

\033[5m Flashing

\033[7M Reverse Display

\033[8m blanking

\033[30m-\33[37m Front View

\033[40m-\33[47m background Color

\033[na the cursor to move n rows

\033[NB cursor down n rows

\033[NC cursor right shifts n rows

\033[nd cursor left n rows

\033[Y;XH Setting the cursor position

\033[2J Clear Screen

\033[k clears the contents from the cursor to the end of the line

\033[s Save Cursor position

\033[u Restore cursor Position

\033[?25l Hide Cursor

\033[?25h Display cursor

Example: the content of the output is required to be underlined and flashing in blue-bottom red characters

Echo-e "\033[31;44;4;5m aaaaaaaaaaaa\033[0m"

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/98/wKioL1eVwGqBcxgAAAAQhSJaQEg447.png "title=" 24.png "alt=" Wkiol1evwgqbcxgaaaaqhsjaqeg447.png "/>


This article is from the "Linux Operational Learning path" blog, please be sure to keep this source http://fengliang.blog.51cto.com/3453935/1829678

Summary of the use of Echo under Linux

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.