(1) Manipulating a file and slicing the file query rows
grep ' XXX ' Cut 2 (or 1-2)
(2) The operation of the file to remove the weight and show the number of repetitions
grep ' xxx ' Cut 2 Sort Uniq -C
(3) View total number of totals rows
grep ' XXX ' Cut 2 Sort Uniq WC -L
Sort : sorts the contents of the text file.
sort-u [File] = sort [File] | Uniq (de-weight)
Parameter description
-B ignores whitespace characters that begin before each line
-c Check that the files are sorted in order
-D sorting, ignoring other characters, in the case of English letters, numbers, and whitespace characters
-f Sort, lowercase letters are considered uppercase
-L when sorting, ignoring other characters except ASCII characters between 040 and 176
-M merges several sorted files
-M sorts the preceding 3 characters according to the abbreviation of the month
-n Sort by numeric size
-o< output File > Tell the sorted result into the specified file
-R sorted in reverse order
-t< separator character > Specify the field segment character to use when sorting
+< start >-< End fields > Sort by a specified field, ranging from the start to the previous field in the End field
--HELP Display Help
--version displaying version information
-U leaves only one row for rows that are considered identical after sorting
Uniq: checks and deletes duplicate rows in a text file.
syntax : uniq[options] File
most important parameters : Default (de-weight) | -D (display weight) | -U (delete weight)
Parameters
-C or--count shows the number of occurrences of the row next to each column
-D or--repeat displays only the rows that appear repeatedly
-f< field > or--skip-fields=< column > ignore compare specified field
-s< character position > or--skip-chars=< character position > Ignore comparison of specified characters
-U or--unique only show one row at a time
-w< character position > or--check-chars< character position > Specifies the character to compare
--help Help Information
--version Version Information
Linux shell command