-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Matthijs De Smedt on 9/7/2007 6:15 AM:
> 
> I've just read the manpage, and I'm still trying to find some text
> explaining the importance of the order of expression elements. I now sort-of
> understand the syntax, but it's very unusual when I'm used to syntax like
> "emerge --unmerge --pretend --verbose package".

Find is required, by POSIX, to avoid reordering expressions once it
encounters a directory name or start of an expression.  Argument
reordering does not make sense in light of expressions.

> Maybe something can be added under "Expressions" explaining exactly how find
> interprets expressions.

Where do you propose adding it?  There is already information there - for
each file name being visited, find evaluates the expression from left to
right until it hits something that evaluates to false.  -delete evaluates
to true if it successfully deletes anything, so by listing it first, you
are asking find to delete a file, and if it fails, then do the next part
of the expression (which finally does name filtering).  Usually, you want
to do the filtering first (for example, -iname returns false if the file
name does not match the pattern), then only -delete what is left.  Maybe
what we should add is a sentence to -delete:

Note that -delete is usually placed at the end of an expression, after all
earlier tests have filtered the list of which files to delete.

> ps. Why is "find -iname *-1*.jpg" invalid? I didn't explicitly indicate the
> path to search so find assumes the working directory.

Because you did not protect it from filename expansion by the shell.  If
your current directory happens to have a single file that matches that
pattern, then you are really invoking "find -iname myfile-1.jpg", which
does not find everything based on the pattern.  And if your current
directory happens to have two or more files that match the pattern, you
have just given find a syntax error, since in "find -iname f1-1.jpg
f2-1.jpg", f2-1.jpg falls in the position of an expected expression, but
does not match any known expression.  You probably meant:

find -iname "*-1*.jpg"

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [EMAIL PROTECTED]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4U9F84KuGfSFAYARAsK6AKCsVVcqY9MXikDeSYGWKY6MmRGvegCgnGjJ
qRfh/AfG2H6ieEiFUJe4D7k=
=xk7P
-----END PGP SIGNATURE-----


Reply via email to