Text Processing for Linux

Source: Internet
Author: User
Tags diff


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.