Day10.awk command and scripting of the shell

Source: Internet
Author: User
Tags nginx reverse proxy

Homework One: awk, the collation of variables

awk Syntax:
-F defines the field delimiter, and the default delimiter is a contiguous space or tab
Use the order of $1,$2,$3 to represent the different fields of each row in files separated by the interval symbol
NF variable indicates the number of fields in the current record
The NR variable represents the number of rows that awk reads in
-V Define variables and assign values can also be borrowed from the shell variable to introduce

Variable:
1. System Variables
Set: Show All variables
ENV: Environment variables
2. Assignment variables
Varname=value
Echo $VARNAME
Delete variable unset VARNAME
3. Common system Variables
PATH, PWD, LANG, HOME, Histsize, PS1, IFS
4. Global variables and local variables
[Email protected] ~]# gender= ' Male ' #在爹这个位置定义一个局部变量gender
[Email protected] ~]# export money=1000 #在爹这个位置定义一个全局变量money
[Email protected] ~]# bash #切换到子bash
[[email protected] ~]# echo $gender #在儿子这里看它爹的局部变量gender, results are empty, not seen
[[email protected] ~]# echo $money #在儿子这里看它爹的全局变量money, you can see 1000
[Email protected] ~]# export hobby= ' Piao ' #在儿子这里定义一个全局变量hobby
[[Email protected] ~]# exit #退出, go into Dad's bash environment
[Email protected] ~]# echo $hobby #爹是看不到儿子的export的, son's son can see

Job Two: awk text processing
Print user names for UID within the 30~40 range

Print the line number and user name of the 第5-10 line

Print odd lines

Print even rows

Print a row with a number of fields greater than 5

Print uid Not equal to GID username

Print a user without a shell specified

Job Three: Shell scripting
Automatic deployment, initial configuration, and startup of Nginx reverse proxy service
Automatic deployment, initial configuration, and launch of three web
Monitoring script: Monitor the memory usage of each machine >70%, then output alarm information
(Idea Tip:
[Email protected] ~]# ((80>70))
[[email protected] ~]# echo $?
0

Day10.awk command and scripting of the shell

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.