Remember to escape grep Regular Expression options

Source: Internet
Author: User

For more information about the grep command, see grep Regular Expressions and options.

The most frequently used parameter is-V, but it is not easy to use.

For example, I want to find a word "userservice", but files like "*. SVN" do not need to be displayed. What should I do?

Grep-R "userservice"./| grep-V "SVN"

However, if I do not display files such as "test, auto_load", what should I do? My previous practices are:

Grep-R "userservice"./| grep-V "SVN" | grep-V "test" | grep-V "auto_load"

The command is very long and troublesome, so I thought that grep itself serves as an option based on a regular expression. Can I use the "or |" command of a regular expression?

Grep-R "userservice"./| grep-V "SVN | test | auto_load"

Obviously, the execution result shows that the above command does not meet my needs, so I am puzzled. It turns out that when you use the regular expression option, remember to escape "|. The final command is as follows:

Grep-R "userservice"./| grep-V "SVN \ | prj \ | test \ | auto_load"

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.