[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestion: verbose option. Doc Update: -print and no action are NOT
From: |
James Youngman |
Subject: |
Re: Suggestion: verbose option. Doc Update: -print and no action are NOT the same |
Date: |
Sat, 2 Apr 2011 13:16:09 +0100 |
On Mon, Mar 28, 2011 at 11:22 PM, Peggy Russell
<address@hidden> wrote:
> Hi,
>
> I have a suggestion and documentation update for `find`.
>
> The suggestion for findutils' find is to add a '-t, --verbose' or '--whatif'
> option similar to the '-t' in `xargs`. At a minimum it would show what `find`
> would generate, but it would not execute anything. Note: The `-D exec`
> option displayed no additional output.
>
> The documentation update is to add a paragraph describing that using the
> default action of `-print` may NOT produce the same result as actually
> supplying the action `-print` because of Boolean operator precedence.
The existing documentation says in the manpage:
If the expression contains no actions other than -prune, -print is per‐
formed on all files for which the expression is true.
And in the info documentation:
You can omit the operator between two primaries; it defaults to
`-and'. *Note Combining Primaries With Operators::, for ways to
connect primaries into more complex expressions. If the expression
contains no actions other than `-prune', `-print' is performed on all
files for which the entire expression is true (*note Print File Name::).
The document doesn't state anywhere that the effect is the same as
adding -print on the end of the expressions (for exactly the reason
you state - the effect would not be the same).
Do you think this is unclear?
>
> find -name tmp -prune -o -name \*.txt
> find -name tmp -prune -o -name \*.txt -print
>
> The lack of an action in the first command means it is equivalent to:
>
> find . \( -name tmp -prune -o -name \*.txt \) -print
>
> This causes tmp to be included in the output. However for the second find
> command the normal rules of Boolean operator precedence apply, so the pruned
> directory does not appear in the output.
>
> As described here: http://content.hccfl.edu/pollock/unix/findcmd.htm
>
> Environment:
> find --version
> find (GNU findutils) 4.4.0
>
> Thank you.
> Peggy Russell
>
>