The Find command in Linux is detailed

Source: Internet
Author: User

http://blog.csdn.net/pipisorry/article/details/39831419

Problem:

Find command found in Linux does not contain some directories

The Find command ignores methods of one or more subdirectories

When searching with Find in Linux, it is sometimes necessary to ignore some directories that do not look for, you can use the-prune parameter to filter, the path parameter to ignore must follow the path of the search, otherwise the parameter will not work.

eg

[email protected]:/tmp1#find./-type f #/tmp1 All files in all folders./file./1/1.cpp./2/2.cpp[email Protected]:/tmp1#find./-  Path./1-prune-o-type f-print #/tmp1 find files but ignore files in Folder/1./file./2/2.cpp[email protected]:/tmp1#find./\ (-path./1-o -path./2 \)-prune-o-type f-print #/tmp1 to find files while ignoring files in folder/1/2./file

Mans Find

-path pattern File Name matches shell pattern pattern. The metacharacters does not treat '/' or '. ' Specially; So, for example, find.   -path "./sr*sc" would print a entry for a directory called './src/misc ' (if one exists).  to ignore a whole directory tree, Use-prune rather than checking every file in the tree. For example, to-skip the directory ' Src/emacs ' and all files and directories under it, and P Rint the names of the other files found, does something like This:find.              -path./src/emacs-prune-o-print Note that the pattern match test applies to the whole file name,              Starting from one of the start points named in the command line.  It would only do sense to use a absolute path name here if the relevant start point was also an absolute   Path.            This means  That this command would never match Anything:find Bar-path/foo/bar/myfile-print T He predicate-path is also supported by HP-UX find and would be in a forthcoming version of the POSIX Standar D....

Parameter-wholename can also be used, but it is not recommended

-wholename pattern              See-path.    This alternative was less portable than-path.

from:http://blog.csdn.net/pipisorry/article/details/39831419


The Find command in Linux is detailed

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.