Difference between-regex and-name of find

Source: Internet
Author: User

Difference between-regex and-name of find 1. the biggest difference with-name and-iname is that-regex uses the entire result output by find (different from the absolute path name) as the object to be matched, not just the last part of the result www.2cto.com example/The tmp directory contains only aaa, aa, 1, 2. The find-name "a *" files can be found in aaa and aa, while the find/tmp-regex "a *" files cannot be found. None of them can be found, because the result is as follows:/tmp/aaa/tmp/aa-name matches the "aaa" and "aa" sections in the result, -regex matches the complete "/tmp/aaa" and "/tmp/aa. so you need to write find/tmp-regex ". *. * "2. note that the above is. * Instead of * www.2cto.com-name, what can be interpreted is based on file glob in shell. Matching characters, including: (1) * represents any length string (2 )? Represents any single character (3) [set] represents an optional character set (4) [^ set] or [! Set] indicates a set (5) brace expansion that uses ASCII as the complete set for [set], that is,/tmp/{a, B, c} is extended to three strings:/tmp/a/tmp/B and/tmp/c. Note that the file globing mechanism of shell is often not considered a regular expression. -regex accepts the Regular Expression of "Orthodox", which has many things to say. Basically, it is the same as the regex mentioned in the emacs document, because the regex Interpretation Section in the find manual is actually the part that links to emacs to explain regex. in the above example, the biggest difference is. * represents any length string.
 

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.