grep is used for keyword search text
-I ignores case when searching
-n Displays the number of rows in the result
-V output row with no keyword
-ax the specified number of rows after the row of the result is included in the output
- BX when the output contains the result of the row before the specified number of rows
grep xxx/etc/passwd in the, etc/passwd text query xxx.
Find/-user linuxcat | grep video queries the root directory for files whose user is linuxcat, outputs all output information to grep through the pipeline, and finds information that contains the video key in the Find output
The cut is used for column-based processing of text content
-D to specify the split character
-F to specify the output column number
-C for character-based cutting cut-c2-6/etc/passwd
cut-d:-f1/etc/passwd use: As a separator, The target file is processed in one column, followed by the first column
grep root/etc/passwd | cut-d: F3
WC for statistical text information
-l count rows
-W only statistics words
-C only count bytes
- M only count characters
sort to sort text content
-R to sort in reverse order
-N to sort by number
-F Ignore Case
-u delete duplicate rows
-TC use C as a delimiter to sort the columns
- KX when sorting based on a specified character into a column, specifies that the column is sorted based on the
Unlq to remove duplicate adjacent rows
diff to compare two files difference
-I ignore case
-B ignore the change of the number of spaces
-U Unified Display comparison information ( Typically used to generate a patch file)
Diff-u linuxcat linuxcat-new>final.patch
TR to process text content
-d delete keyword
tr-d ' TMD ' <linxcat
Convert case
tr ' A-Z ' A-z ' <linuxcat
sed to search for and replace text
sed ' s/cat/ac/g ' 333 replaces all the cat in the text named 333 with AC. G represents the replacement of all, you can also specify how many lines are replaced, sed ' 1,20s/... ' ... Represents the substitution of rows 1 through 20, with the-e parameter to specify multiple
Text processing for Linux