[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using the 'find' program

On Mon, Sep 05, 2005 at 09:12:41AM -0400, Kevin Coyner wrote:
>     cd /tmp
>     touch testfile
>     find . -iname testfile -print
> and I get nothing.

On my end that works perfectly. You do, indeed, have the
syntax right. Here's what I get:

(09:16) slaniel@TheloniousMonk:~$ cd /tmp
(09:16) slaniel@TheloniousMonk:/tmp$ touch testfile
(09:16) slaniel@TheloniousMonk:/tmp$ find . -iname testfile

It should work fine on your end, too. See below; I think you
did something incorrectly.

Incidentally, I think '-print' is superfluous; I'm pretty
sure the default is to print.

> I also tried:
>     find /tmp -iname testfile -print
>         and
>     find /tmp -iname 'testfile' -print

All of those should work. Note that the second alternative
-- the one with testfile between single quotes -- is more
work than you need. The only reason to put quotes around a
string is if the string contains some characters that the
shell would interpret strangely. For instance, if it were
'test file', you'd want the quotes. But with just
'testfile', quotes are unnecessary.

> find: warning: Unix filenames usually don't contain slashes (though
> pathnames do).  That means that '-iname /tmp' will probably evaluate
> to false all the time on this system.  You might find the
> '-wholename' test more useful, or perhaps '-samefile'.
> Alternatively, if you are using GNU grep, you could use 'find ...
> -print0 | grep -FzZ /tmp'.

This suggests that you typed

find . -iname /tmp

or somesuch. Please resend by copying and pasting directly
from the command that you typed; I think you'll find that
you made a typo in your use of 'find'.

>     find . -type f -exec file '{}' \;
> which returns nothing.

Again, if you please: copy from the command line into an
email, including any errors you got.

Stephen R. Laniel
+(617) 308-5571
PGP key: http://laniels.org/slaniel.key

Attachment: signature.asc
Description: Digital signature

Reply to: