SoloCDM wrote:
> 
> How is it possible to force the find command to list all files with
> "read" in the filename, regardless whether they start with a period
> or not?
> 
> I already tried the following:
> 
>    find /usr -iname ".*read*" -iname "*read*" -type f -print

This is a question I sometimes ponder too...  the quick answers offered so far
do not address this question thoroughly enough...

Here is the acid test:  

What commands to use to find the file:  ~/.netscape/.mailcap  ???

find:  looks through directory ".netscape"; but does not find ".*" files

Here's a test to see how find fails to find files...

$ mkdir .test
$ mkdir -p .test/test1/test2; mkdir -p .test/.test1/.test2
$ touch .test/test1/TEST1
$ touch .test/test1/test2/TEST2
$ touch .test/.test1/.TEST1
$ touch .test/.test1/.test2/.TEST2
$ ls -R .test
.test:
test1/
 
.test/test1:
TEST1  test2/
 
.test/test1/test2:
TEST2

First, let's see if find sees all the files...

$ find .test
.test
.test/test1
.test/test1/test2
.test/test1/test2/TEST2
.test/test1/TEST1
.test/.test1
.test/.test1/.test2
.test/.test1/.test2/.TEST2
.test/.test1/.TEST1

>From the above output, we KNOW that find at least looks at all the files
(including hidden files and directories)...

Specifying an explicit hidden directory as the starting point:

$ find .test -iname '*test*' -print
.test/test1
.test/test1/test2
.test/test1/test2/TEST2
.test/test1/TEST1
$

This confirms that find does not check nested hidden files/directories.  In
order to find the remaining hidden files, we need to execute a second version of
the find command:

$ find .test -iname '.test*' -print
.test
.test/.test1
.test/.test1/.test2
.test/.test1/.test2/.TEST2
.test/.test1/.TEST1

which of course will not find the files in the first set above (no leading
".")...  This shows that find will look at nested hidden files/directories in
this example.

How to combine the search...

$ find . -iname test\* -iname .test\* -print
$

doesn't work...  that's an IMPLIED "-a|-and" as in:

$ find . -iname test\* -and -iname .test\* -print
$

The following variations:

$ find . -iname test\* -or -iname .test\* -print
./.test
./.test/.test1
./.test/.test1/.test2
./.test/.test1/.test2/.TEST2
./.test/.test1/.TEST1
# Reverse the test...
$ find . -iname .test\* -or -iname test\* -print
./.test/test1
./.test/test1/test2
./.test/test1/test2/TEST2
./.test/test1/TEST1

show that only the test to the right of "-or" is used...  

Trying to force both (see bottom of "man find"):

$ find .test -iname .test\* , -iname test\* -print
.test/test1
.test/test1/test2
.test/test1/test2/TEST2
.test/test1/TEST1
# Reverse the test...
$ find .test -iname test\* , -iname .test\* -print
.test
.test/.test1
.test/.test1/.test2
.test/.test1/.test2/.TEST2
.test/.test1/.TEST1

does not help either...

I would think this indicates that "find" is buggy since the "-o|-or|," does not
seem to work as documented...  comments...?

Pierre

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to