Shell Learning Note 1

Source: Internet
Author: User

Knowledge point 1, modify the color of the output

Echo-e "\e[1;31m This is red text \e[0m"

Where \e[1;31m indicates that the output is displayed in red, the \E[0M logo resets the color, and 31 can be replaced by a different color value, which is used to customize the text and background of the color.

Each color has a corresponding color code. For example: reset = 0, black = 30, red = 31, green = 32.

To set the color background, the frequently used color code is: reset = 0, black = 40, red = 41, green = 42, yellow = 43, blue = 44, magenta =45, cyan = 46, white =47

Knowledge point 2, viewing environment variables for a program

First step: pgrep node #获取某个程序的pid, node is replaced with the corresponding program name.

Step two: cat/proc/$pid/environ | Tr ' s ' \ n ' # $pid replaced with the corresponding process ID, and the pipe will replace the null character of the output with the line break

Knowledge point 3, Integer plus subtraction, in Ubuntu, the following method is feasible, other methods seem to be less feasible.

#!/bin/bashno1=4; NO2=5; result=$ ((no1+NO2))Echo $result

Save to be continued ....

Shell Learning Note 1

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.