Linux-grep Basic Usage __linux

Source: Internet
Author: User

The grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching rows. This command is often used to parse a line of information, if it has the information we need, to display the line, which is usually used with the pipe command, to filter the output of some commands, and so on, and its simple syntax is:

grep [-ACINV] [--color=auto] ' find string ' filename

Options and Parameters:
-A: Find data in text file as binary file
-C: Calculates the number of find ' Find string '
-I: Ignore case difference, that is, the case is treated as the same
-V: Reverse selection, which shows the line with no ' find string ' content

-N: By the way output line number
 
--color=auto: Can be found in the keyword part of the color display

For example:

1.



2. Displays all the lines that contain w in a file that starts with P.



3. Displays the rows that match wh in the Hellob.txt,pear.txt file.




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.