Get the App
SLTechnology News&Howtos  ›  Servers  › 

Count the first 20 IP addresses of port 22 of the currently connected server

Shulou Source: shulou.com Published: 2022-06-02 08:35:11 10月24日 Update

Netstat-nat | grep "192.168.100.102 awk" | awk'{print $5}'| awk-F':'{print $1}'| sort | uniq-c | sort-nr | head-20

Sort:

Function description: sort the content of the text file, and sort can sort the content of the text file by behavior unit.

Copy the code

Parameters:

-b ignores space characters that begin at the beginning of each line.

-c check whether the files have been sorted in order.

When sorting, ignore other characters except alphabetic, numeric and space characters.

When sorting, lowercase letters are treated as uppercase letters.

When sorting, all characters except ASCII characters between 040 and 176are ignored.

-m merges several sorted files.

-M sorts the first three letters according to the abbreviation of the month.

-n is sorted by the size of the number.

-o saves the sorted results to the specified file.

-r is sorted in reverse order.

-t specifies the field delimiter used for sorting.

+-sorts by the specified field, ranging from the start field to the previous field of the end field.

-- help displays help.

-- version displays version information

Uniq:

Usage: uniq [option]. [file]

Filter adjacent matching lines from the input file or standard input and write to the output file or standard output.

When no options are attached, the matching rows will be merged at the first occurrence.

The parameters that must be used for long options are also required for short options.

-c,-- count prefixes each line with a prefix number indicating the number of occurrences of the corresponding line header

-d,-- repeated outputs only duplicate lines

-D,-- all-repeated [= delimit-method shows all duplicate lines

Delimit-method= {none (default), prepend,separate}

The limit of empty behavior

-f,-- skip the first N columns when skip-fields=N comparison

-I,-- ignore-case is not case-sensitive when comparing

-s,-- skip the first N characters in skip-chars=N comparison

-u,-- unique displays only unique lines

-z,-- zero-terminated uses'\ 0' as the line Terminator instead of a new line feed

-w,-- check-chars=N does not compare the content after the nth character of each line

-- help displays this help and exits

-- version displays version information and exits

If the field is a blank character (usually includes spaces and tabs), and then a non-empty character, the empty character before the character in the field will be skipped.

Tip: uniq does not check for duplicate rows unless they are adjacent rows.

If you want to sort the input first, use "sort-u" without uniq.

Tags: Sort character file letter information content blank character space input output size text standard version order help check between code tab Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Shulou Technology Apple OPPO Reno