From f87d0d2ae87a387fcf90acc559dd7b4863e09919 Mon Sep 17 00:00:00 2001 From: jay Date: Sat, 30 Jun 2007 18:33:20 +0000 Subject: [PATCH] Added complex example to find manpage --- ChangeLog | 3 +++ find/find.1 | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4b530f3..fc8dc45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-06-30 James Youngman + * find/find.1 (EXAMPLES): Added an example of using find and cpio -p + to copy a directory tree, with pruning and omitted files. + * find/pred.c (format_date): Use verify_true for constant conditions rather than assert. * xargs/xargs.c (main): Ditto. diff --git a/find/find.1 b/find/find.1 index 27226d8..1f95675 100644 --- a/find/find.1 +++ b/find/find.1 @@ -1369,6 +1369,45 @@ everybody (\-perm \-444 or \-perm \-a+r), have at least on write bit set (\-perm /222 or \-perm /a+w) but are not executable for anybody (! \-perm /111 and ! \-perm /a+x respectively) +.P +.nf +.B cd /source-dir +.B find . -name '.snapshot' \-prune \-o \e( \e! \-name '*~' \-print0 \e)| +.B cpio -pmd0 /dest-dir + +.fi +This command copies the contents of +.B /source-dir +to +.BR /dest-dir , +but omits files and directories named +.B .snapshot +(and anything in them). It also omits files or directories whose name +ends in +.BR ~ , +but not their contents. The construct +.B \-prune \-o \e( ... \-print0 \e) +is quite common. The idea here is that the expression before +.B \-prune +matches things which are to be pruned. However, the +.B \-prune +action itself returns true, so the following +.B \-o +ensures that the right hand side is evaluated only for those +directories which didn't get pruned (the contents of the pruned +directories are not even visited, so their contents are irrelevant). +The expression on the right hand side of the +.B \-o +is in parentheses only for clarity. It emphasises that the +.B \-print0 +action takes place only for things that didn't have +.B \-prune +applied to them. Because the default 'and' condition between tests +binds more tightly than +.BR \-o , +this is the default anyway, but the parentheses help to show +what is going on. + .SH EXIT STATUS .PP .B find -- 2.11.4.GIT