Let the echo output in the shell script color

Source: Internet
Author: User


There are two ways to bring the echo output color

    1. Define color variables in shell scripts, use ECHO-E to call variables

    2. When defining a variable, define the ECHO-E in the variable, and then output the variable

Shell script that lets echo output display color

#!/bin/bash# defines the color of the variable red_color= ' \e[1;31m '    #红GREEN_COLOR = ' \e[1;32m '   #绿YELOW_COLOR = ' \e[1;33m '   #黄BLUE_COLOR = ' \e[1;34m '    #蓝PINK = ' \e[1;35m '        #粉红RES = ' \e[0m ' # Need to use echo -eecho -e   "${red_color}======red color======${res}" echo -e   "${yelow_color}======yelow color======${res}" echo -e   "${blue_color}======green color ======${res} "echo -e  " ${green_color}======green color======${res} "echo -e    "${pink}======pink color======${res}" echo  "################################################### ########## "#直接把echo  -e into the variable, the use of direct output variables can be setcolor_success=" echo -en \\033[1;32m "Setcolor_ Failure= "echo -en \\033[1;31m" setcolor_warning= "echo -en \\033[1;33m" SETCOLOR_NORMAL= "Echo  -en \\033[0;39m "echo ----oldboy trainning-----   &&  $ setcolor_successecho ----oldboy trainning-----   &&   $SETCOLOR _failureecho ----Oldboy  trainning-----   &&   $SETCOLOR _warningecho ----oldboy  Trainning-----   &&   $SETCOLOR _normal

The script execution results are as follows

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/56/BF/wKiom1SMCb2QwDj9AAEajUJn-Fc907.jpg "title=" Echo_ Color.png "alt=" Wkiom1smcb2qwdj9aaeajujn-fc907.jpg "/>




This article from "Plum blossom fragrance from bitter cold" blog, please be sure to keep this source http://wangjunkang.blog.51cto.com/8809812/1589606

Let the echo output in the shell script color

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.