Performing a search from the current directory where this file resides, this find command finds the file.

# find . page.tpl.php

However, when I search from a child directory, this command,

# find ../. page.tpl.php

prints out the list of files, WITH the requested file listed in the output,


However, the results are,

find: `page.tpl.php': No such file or directory

Then when I add the -name argument it works,

# find ../. -name page.tpl.php

I simply forget to use arguments sometimes and the false negative is really aggravating. What's going on?

  • There is no false negative here. The program has done exactly what you asked and returned the correct results. A better question would be "Why does find have such funny commandline syntax?" or "What exactly is find doing here?" – dmckee Jun 16 '11 at 21:15
  • I believe my question to be appropriate. If you want to ask a "better question" you are, of course, free to do so. – xtian Jun 20 '11 at 17:05
  • Follow-UP Trying RedGrittyBrick's advise, I used the relative path .. instead of ../. on another file "ts-unix-find" and this time it worked. I thought I made a mistake in my post. Then I noticed the dot syntax. Sure enough, when I renamed the file "ts-unix-find.save" and performed the first two find commands above, I repeated the behavior. Evidently a find command with a relative path .. and an "expression" containing a dot doesn't work. Now I want to understand this "expression" distinction... (^_^) – xtian Jun 20 '11 at 17:18

find [path] [expressions]

A filename isn't an expression.

The default action is to print.

For path, ".." is better than "../." you almost never need to include "." unless it's at the start of a relative path.

  • Ok. I appreciate the methodical way you answered my post. That a file name isn't an expression is a lost distinction, which is to say I know you are making a distinction, but I don't understand what it means. And the default print action is perfectly fine. Actually I would want to force the print action when using -name, but it remains silent. I tried .. and learned something which is in a comment follow-up... – xtian Jun 20 '11 at 17:10

The command find uses:
find [-H] [-L] [-P] [path...] [expression]

Your first example was:
find ../. page.tpl.php

What you did was give find two search paths. As the default expression is print, the contents of the two paths were printed to stdout.

Consider this:

mkdir a b c 
touch  a/file1 a/file2 b/SANTACLAUS c/MONKEYS
find a b

$ find a b

Your second example was:

Here you provided one search path. The error tells you that page.tpl.php wasn't found in CWD. I assume this was due to your not having the file 'page.tpl.php' under the directory 'parent_dir'.

  • No. The file was there. I first performed the find in the same directory. Then descended into a child directory and performed the same find with the relative path ../. I never moved the file, it was still there. – xtian Jun 20 '11 at 17:12

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.