On Sun, Aug 5, 2012 at 11:59 PM, Peng Yu <pengyu...@gmail.com> wrote: > Hi, > > /tmp/main$ find . -path '*/tmp*' > /tmp/main$ find /tmp/main -path '*/tmp*' > /tmp/main > > > The above commands show that -path match the whole path (/tmp/main)
They match the path of the file beginning with the start point named on the command line. This is an absolute path if the start point is an absolute path. Otherwise it is not. > rather than the relative path ('.'). Is there a way to always use the > relative path so that both of the above commands returns nothing? In general, the answer to your question as-phrased is no. But $ find /tmp/main -path '*/tmp*' should also return /tmp/main/foo/tmp/blah if it exists. So perhaps if you could more clearly state what you are trying to achieve, the people on the list can give a clear and more helpful answer. If, for example you simply want to find files below subdirectories whose basename has a prefix "tmp" you can do so like this: ( cd "/tmp/main" && find . -path '*/tmp*' ) For some other kinds of problem it can be helpful to use the %P format specifier. But you didn't explain what problem you are trying to solve, so it's hard to give advice which is more useful at this stage. Could you explain please what you are trying to do? Thanks, James.