Shell-5.shell echo Command

Source: Internet
Author: User
Tags clear screen echo command echo display

Shell-5.shell echo Command

Echo---display content

Format: Echo [options] Text
-N Do not wrap in the last line
-E parsing escape character
\a issued a warning sound
\c Finally, no newline symbol is added.
\f Line break
\ r Enter


1.-N do not wrap in the last line
[[email protected] ~]# Echo-n "My name is"; echo "Yuanji"
My name is Yuanji
[[email protected] ~]# echo "My name is"; echo "Yuanji"
My name is
Yuanji

2.-e parsing escape character
[Email protected] ~]# ECHO-E "There is three empty lines.\n\n\n"; echo "------"
There is three empty lines.



------
[Email protected] ~]# echo "There is three empty lines.\n\n\n"; echo "------"
There is three empty lines.\n\n\n
------

3. ECHO-E Display Color(This part comes from http://www.cnblogs.com/lr-ting/archive/2013/02/28/2936792.html, the author writes very clearly)
----------------------------------
echo Display in shell script with color display, echo display with color, need to use parameter-E
The format is as follows:

Echo-e "\033[word background color; text color m string \033[0m"
For example:
Echo-e "\033[41;36m something here \033[0m"

Where 41 of the position represents the background, 36 of the position is the color of the word
Note:
1, the word background color and the text color is in English ""
2. There is a m behind the text color
3, before and after the string can have no space, if any, the output is also a space
Here is the corresponding word and background color, you can try to find out the different color collocation
Cases

Echo-e "\033[31m Red word \033[0m"
Echo-e "\033[34m Yellow word \033[0m"
Echo-e "\033[41;33m Red bottom yellow word \033[0m"
Echo-e "\033[41;37m Red bottom White \033[0m"

Word Color: 30-–37
Echo-e "\033[30m Black character \033[0m"
Echo-e "\033[31m Red word \033[0m"
Echo-e "\033[32m Green word \033[0m"
Echo-e "\033[33m Yellow word \033[0m"
Echo-e "\033[34m Blue word \033[0m"
Echo-e "\033[35m Purple word \033[0m"
Echo-e "\033[36m sky blue Word \033[0m"
Echo-e "\033[37m White character \033[0m"

Word background color range: 40-–47
Echo-e "\033[40;37m Black Bottom White \033[0m"
Echo-e "\033[41;37m Red bottom White \033[0m"
Echo-e "\033[42;37m Green bottom White \033[0m"
Echo-e "\033[43;37m Yellow \033[0m"
Echo-e "\033[44;37m Blue bottom White \033[0m"
Echo-e "\033[45;37m Purple \033[0m"
Echo-e "\033[46;37m sky blue Bottom White \033[0m"
Echo-e "\033[47;30m black character \033[0m on white background"

Last Face Control option description
\33[0m Close All Properties
\33[1m Setting High brightness
\33[4m Underline
\33[5m Flashing
\33[7M Reverse Display
\33[8m blanking
\33[30m-\33[37m Setting the foreground color
\33[40m-\33[47m Setting the background color
\33[na the cursor to move n rows
\33[NB cursor down n rows
\33[NC cursor right shifts n rows
\33[nd cursor left n rows
\33[Y;XH Setting the cursor position
\33[2J Clear Screen
\33[k clears the contents from the cursor to the end of the line
\33[s Save Cursor position
\33[u Restore cursor Position
\33[?25l Hide Cursor
\33[?25h Display cursor
----------------------------------


4. Example: In the following section you will see the function defined in the SH file (part of the function is followed up)
[email protected] ~]# cat four.sh
#!/bin/sh
Echo_title () {
Echo-e "\n#############################"
Echo-e "# \033[1m$1\033[0m"
echo "#############################"
}

Echo_red () {
Echo-e "\033[0;31;1m$1\033[0;31;0m"
}

Clear
Echo-n "Operation_date:"
Echo_red "' Date '"
Echo-n "Operator:"
echo_red "' ID '"

# Basic Information
Echo_title "Basic Information"
ECHO-E-N "kernel\t\t:"
Echo_red "' Uname-a '"
ECHO-E-N "hostname\t:"
echo_red "' hostname '"

Show results

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/80/0A/wKioL1c1f17AK3e4AAGYVoK2vjE076.jpg "title=" 9 "alt= "Wkiol1c1f17ak3e4aagyvok2vje076.jpg"/>

This article from the "Go to the Origin dimension" blog, reproduced please contact the author!

Shell-5.shell echo Command

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.