★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