Notes on using the echo command in Linux

Source: Internet
Author: User

Notes on using the echo command in Linux

1. Instructions for using the echo command: echo sends the input string to the standard output. The output strings are separated by blank characters, and the line number is added at the end. Function: display character Syntax: echo [-neE] [String] common options of echo command: 1,-n: do not enable automatic line feed


2.-e: it is usually used in combination with the Escape Character "\" to make the Escape Character take effect (if the following characters appear in the string, It is specially processed, rather than treated as a general text output)
\ A sends an alert


\ B Delete the previous character


\ C suppresses the characters after the output and does not wrap automatically


\ E Delete the last character


\ N force line feed


\ R move the cursor to the beginning of the line, but do not wrap the line, it will overwrite the character at the beginning of the line


\ T insert horizontal Tab


\ V insert vertical Tab


\ Insert \ symbol


3.-E: Enable the Escape Character of the backslash to take effect (default)


4. Output of variable values. Usage: echo $ variable name


5. Double quotation marks: indicates weak reference, and the variable will be replaced


6. single quotation marks: indicates a strong reference, and the variable will not be replaced.



2. echo outputs the content of the specified color. 1. Usage: the format of echo-e "\ 033 [foreground color must be combined with" \ 033; background color m string \ 033 [0m "Note: foreground color and background color positions can be exchanged foreground color: 30m-37m Black: echo-e "\ 033 [30 m black word \ 033 [0 m" RED: echo-e "\ 033 [31 m red word \ 033 [0 m" Green: echo-e "\ 033 [32 m green word \ 033 [0 m" Yellow: echo-e "\ 033 [33 m yellow word \ 033 [0 m" Blue: echo-e "\ 033 [34 m Blue Word \ 033 [0m" Purple: echo-e "\ 033 [35 m purple word \ 033 [0 m" Sky Blue: echo-e "\ 033 [36 m sky blue characters \ 033 [0 m" White: echo-e "\ 033 [37 m White words \ 033 [0 m"


Background Color: 40m-47m Black: echo-e "\ 033 [40 m black bottom \ 033 [0m" Red: echo-e "\ 033 [41 m Red Bottom \ 033 [0m" Green: echo-e "\ 033 [42 m green bottom \ 033 [0 m" Yellow: echo-e "\ 033 [43 m yellow bottom \ 033 [0m" Blue: echo-e "\ 033 [44 m blue bottom \ 033 [0 m" Purple: echo-e "\ 033 [45 m purple bottom \ 033 [0 m" Sky Blue: echo-e "\ 033 [46 m sky blue bottom \ 033 [0 m" White: echo-e "\ 033 [47 m white background \ 033 [0m"


For example, echo-e "\ 033 [31; 43 m aaaaaaaaaaaa \ 033 [0 m" is displayed in the red text of the Yellow Base"


2. Control Option description \ 033 [0 m close all properties \ 033 [1 m set high brightness \ 033 [4 m underline \ 033 [5 m flashing \ 033 [7 m reverse display \ 033 [8 m blanking \ 033 [30 m-\ 33 [37 m foreground color \ 033 [40 m-\ 33 [47 m background color \ 033 [nA cursor move n rows up \ 033 [move the nB cursor down n rows \ 033 [move the nC cursor right n rows \ 033 [move the nD cursor left n rows \ 033 [y; xH set the cursor position \ 033 [2J clear screen \ 033 [K clear content from the cursor to the end of the line \ 033 [s Save the cursor position \ 033 [u restore the cursor position \ 033 [? 25l hide the cursor \ 033 [? 25 h: the cursor is displayed. For example, the content of the output content must be blue-bottom red letters with underlines and echo-e "\ 033 [31; 44; 4; 5 m aaaaaaaaaaaa \ 033 [0 m"

This article permanently updates the link address:

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.