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

Re: using the 'find' program



Kevin Coyner wrote:
> I've been using linux for quite a while but am still perplexed by
> the proper usage of the 'find' program.  I always end up using
> locate instead.  Anyway, I need it now so I re-read the man and
> tried the following:
> 
>     cd /tmp
>     touch testfile
>     find . -iname testfile -print
> 
> and I get nothing.

This should work.  It works for me fine.  Do you have a locale setting
problem?  The -iname will do strcasecmp(3) and that respects the
current locale setting.  What is the output of these commands:

  locale

  perl -e 0

Does this work?

  cd /tmp
  touch testfile
  find . -name testfile -print

> I also tried:
> 
>     find /tmp -iname testfile -print
>         and
>     find /tmp -iname 'testfile' -print
> 
> and still get no decent results.  Instead, I get this error msg:
> 
> 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'.

The results you post look like there is a bug in the option processing
of find.  Since this is such a fundamental utility I can't believe
that no one else has run into this problem.  Also both the Debian
maintainer for find and the upstream maintainer are exceptionally
diligent and work hard to maintain it.  So I am still guessing this is
something broken on your individual system such as a locale problem.

Since none of those things make sense it must be something simpler.
Do you have an alias for find?  Do you have a wrapper script called
find that wraps it?

What does this say?

  type find

Does this work?

  cd /tmp
  touch testfile
  /usr/bin/find . -name testfile -print

> Now these are basic examples right from the man.  Why can I not even
> get these to work?

Check your locale settings.  Check your aliases.  Check for local
wrappers.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: