Table of contents
One, cut: column interception tool
Second, the sort content sorting tool
One, cut: column interception tool
- The cut command cuts bytes, characters and fields from each line of a file and writes these bytes, characters and fields to standard output.
- If no file parameter is specified, the cut command will read standard input. One of the -b, -c or -f flags must be specified.
- Options
-b | Truncate by Byte |
-c | Truncate by character, commonly used in Chinese |
-d | Specify what is the delimiter to intercept, the default is tab |
-f | channel with -d |
Second, the sort content sorting tool
It is a tool that sorts the contents of files in units of rows, and can also be sorted according to different data types. For example, data and character ordering are not the same.
grammar
sort [选项] 参数
Common options
-t | Specify the separator, the default is to use TAB or space to separate |
-k | Specify the sorting area, which range is sorted |
-n | Sort by number, default is text sorting |
-in | Equivalent to uniq, it means that the same number is only displayed on one line, mainly: if there is a space at the end of the line, it will not succeed. |
-r | Reverse sorting, the default is ascending -r is descending |
-O | Dump the sorted results to the specified file |
Without any options, the default is in ascending order on the first line, and the letters are from a to z.
Sort the third column by number size (ascending order) with colon as separator
The output result is not output on the screen, but is output to the file plus.
Remove duplicate lines from file (duplicate lines can be discontinuous)
Three, uniq
Mainly used to deduplicate consecutive repeated lines
Note: It is a continuous line, so it is usually used in combination with sort to sort it into a continuous line before performing the deduplication operation, otherwise the discontinuous repeated line cannot be deduplicated.
grammar
uniq [选项] 参数
Common options
-c | Count duplicate rows |
-d | Show only duplicate rows |
-in | Only show rows that appear once |
Only show rows that appear once
4. tr
tr: He can replace one character with another character. Or some characters can be removed entirely. It can also be used to remove duplicate characters
grammar
用法:tr [选项] SET1 [SET2]
从标准输入中替换,缩减或删除字符,并将结果写到标准输出
Common options
-d | delete character |
-s | Delete all repeated characters, keep only the first one |
delete character