9.Linux Command line Text Processing tool
• Search text grep based on keyword
· grep ' Test ' /etc/passwd keyword search,
· Find/-user Test | grep Video Search in the results, Find the output is text, and then grep keyword,
• Options: - I. , ignoring case,
-N, displays the number of rows where the result is,
-V, which displays the row that excludes the keyword,
-ax, display the keyword and the following x line,a=after,
-BX, display keywords and front x rows,b=before,
--color=auto keywords are displayed in color,
• Column-based processing of text content cut
· cut-d:-f3/etc/passwd- put passwd A colon is a delimiter that cuts a row into columns, showing the third column of each row,
· grep test/etc/passwd | cut-d:-f3 Look in the results,
· cut-c2-6/etc/passwd find each line of 2-6 the characters,
• Options: - D , specifying delimited characters ( tab is the default ) ,
-F, specify the column number of the output,
-C, delimited based on characters,
• Statistical text information WC (word count)
· WC [ option ]passwd
• Options: - L , counting only the number of rows,
-W, only the words are counted,
-C, counting only bytes,
-M, counting only the number of characters,
· sorting text content sort ,
· sort passwd display after sorting, do not change the original file order
• Options: - R , in reverse order,
-N, sorting based on numbers
-F, ignoring case
-U, delete duplicate rows
-t C, sorting columns byusing C as a delimiter
-K x, when sorting based on the specified character as a column, specifies the sort based on that column,
Uniq is used to delete adjacent duplicate rows
· compare the differences between two files diff, diff test Test1
• Options: - I. , ignoring uppercase and lowercase
-B, ignore the change in the number of spaces
-U, unified display of comparison information, commonly used to generate patch files,diff-u test test1 > Final.patch
• Processing of text content tr, Translate
· tr-d ' TMD ' < Test Delete keywords in file
· TR ' A- z "' A- z ' < The casing in the test conversion file
• Search for and replace text sed,
• Involves regular expressions, slightly
9.Linux command line Text Processing tool