Specifies the characters in the awk Regular Expression matching column.

Source: Internet
Author: User

★Example 1
◆ Print the rows whose names start with 80 and end with 80 in the specified Column
● Link symbol comments
~ Relational operators
~ Match Regular Expressions
!~ Do not match Regular Expression

[Root @ xingfujie ~] # Cat a.txt
Afjdkj 80
Lkdjfkja 8080
Dfjj 80
Jdsalfj 808080
Jasj 80
JG 80
Xingfujitsu 80
80 ajfkj
ASF 80
80 xingfujie
[Root @ xingfujie ~] # Awk '{if ($2 ~ /^ 80 $/) print} 'a.txt
Afjdkj 80
Dfjj 80
Jasj 80
JG 80
Xingfujitsu 80
ASF 80

★Example 2
● Example 2.1
◆ Grep-v ffff: Filter IPv6 addresses. The following lines are displayed: 80. Delete the rows from A to Z and _. The row is determined as a separator and the row with the third column equal to 80 is printed.
[Root @ xingfujie ~] # Netstat-Nat | grep-v ffff | grep ": 80" | tr-d "[A-Z] [_]" | awk-F: '{if ($3 = 80) print }'
TCP 0 0 10.15.201.29: 38393 123.125.106.196: 80
TCP 0 0 10.15.201.29: 38383 60.28.236.116: 80
TCP 0 0 10.15.201.29: 44949 60.28.236.112: 80
TCP 0 0 10.15.201.29: 41445 60.28.236.116: 80
TCP 0 0 10.15.201.29: 47630 60.28.236.112: 80
TCP 0 0 10.15.201.29: 48624 60.28.236.116: 80
TCP 0 0 10.15.201.29: 48129 60.28.236.116: 80
TCP 0 0 10.15.201.29: 48837 60.28.236.112: 80
TCP 0 0 10.15.201.29: 50506 60.28.236.112: 80
TCP 0 0 10.15.201.29: 53923 60.28.236.112: 80
● Example 2.2
◆ Correct results can be found without grep ": 80"
[Root @ xingfujie ~] # Netstat-Nat | grep-v ffff | tr-d "[A-Z] [_]" | awk-F: '{if ($3 = 80) print }'
TCP 0 0 10.15.201.29: 60047 118.67.112.70: 80
TCP 0 0 10.15.201.29: 49038 123.125.106.196: 80
TCP 0 0 10.15.201.29: 37035 123.125.106.196: 80
TCP 0 0 10.15.201.29: 35936 118.67.112.70: 80
TCP 0 0 10.15.201.29: 35972 60.28.236.112: 80
TCP 0 0 10.15.201.29: 35056 60.28.236.116: 80
TCP 0 0 10.15.201.29: 48777 60.28.236.112: 80
TCP 0 0 10.15.201.29: 47173 60.28.236.116: 80
TCP 0 0 10.15.201.29: 53014 60.28.236.116: 80
TCP 0 0 10.15.201.29: 51816 60.28.236.112: 80
TCP 0 0 10.15.201.29: 53109 60.28.236.112: 80
TCP 0 0 10.15.201.29: 52274 60.28.236.112: 80
TCP 0 0 10.15.201.29: 49854 60.28.236.116: 80
TCP 0 0 10.15.201.29: 50339 60.28.236.112: 80
TCP 0 0 10.15.201.29: 60595 60.28.236.116: 80

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.