Linux Text Processing

Source: Internet
Author: User

Grep

command grep to search for text based on keywords

grep ' HHL '/etc/passwd

-I ignores case

-N Displays the number of rows in which the result

-V Output lines without keywords

-ax the specified number of rows after the row of the result is included in the output

-BX the specified number of rows before the result row is included in the output

processing text based on columns

Command cut to process text content based on columns

Cut-d:-f1/etc/passwd

grep hhl/etc/passwd | Cut-d:-f1

-D Specify delimiter

-f Specifies the output column number

Text statistics

Command WC for statistical text information

-L Number of rows

-W Word

-C Word Count

-M character Count

Text sorting

Sort the text content by command sort

-R Reverse

-N Sort By numbers

-F ignores case

-U Delete Duplicate rows

-T C uses C as a delimiter to sort columns

-K x when sorting based on the specified character as a column, specify sort based on that column

Text comparison

Diff command

Diff AA Aa-new

-I ignores case

-B Ignore the comparison of the number of spaces

-U Unified Display comparison information

Working with text content

command TR to process text content

Delete keyword

tr-d ' keywords ' < target directory

Transformation

TR AA AA < target directory (convert AA to AA)

Search replacement

Sed to search for and replace text

Sed ' regular expression ' target file

Linux Text Processing

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.