9

The find command provides the option -path. I understand that one has to define where to start looking [commonly known as "path"]. Trying to figure out what it is used for, I found many examples using find -path -prune to exclude some paths.

Question: An explanation what find -path does; what this option is used for.

Please note: It seems crystal clear to me, but then doesn't work as I guessed it would. I worked through the man and the info pages, but I don't get the full meaning of this option.

EDIT As I understand it: find /some/path -name stuff should start looking for "stuff", starting in the directory "path" which is a subdirectory of "some". Works. But then, what does the -path option define? Definitions including sentences like

do not treat / or . specially

doesn't help much and are even more confusing.

  • 5
    Don't you think that "It seems crystal clear, but then doesn't work as I guessed it would" is worth an example? – Hauke Laging Jul 1 '13 at 18:34
5

-path does not (re)define the start path. It refers to the combination of the start path and the relative path of the currently examined object.

You may by this e.g. find all files within a subdirectory src no matter on which level.

"do not treat / or . specially" means that * can match both file names including the extension and into subdirectories: [...]/file* would match both /file.txt and /files/foo.bar

11

It's used for globbing the entire current path. If you have -path '*bin/*rch' and you're currently looking at /sbin/ausearch then it will match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.