[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] Add find -prune|cpio example to find manpage
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH] Add find -prune|cpio example to find manpage |
Date: |
Wed, 27 Jun 2007 00:56:14 +0100 |
2007-06-27 James Youngman <address@hidden>
* find/find.1 (EXAMPLES): Added an example of using find and cpio -p
to copy a directory tree, with pruning and omitted files.
Signed-off-by: James Youngman <address@hidden>
---
ChangeLog | 5 +++++
find/find.1 | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 16df7da..4b4c71e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-27 James Youngman <address@hidden>
+
+ * find/find.1 (EXAMPLES): Added an example of using find and cpio -p
+ to copy a directory tree, with pruning and omitted files.
+
2007-06-26 James Youngman <address@hidden>
* find/tree.c (get_pred_cost): Eliminate unused variable.
diff --git a/find/find.1 b/find/find.1
index 27226d8..a249d09 100644
--- a/find/find.1
+++ b/find/find.1
@@ -1369,6 +1369,44 @@ 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
+.B \-o this is the default anyway, but the parentheses help to show
+what is going on.
+
.SH EXIT STATUS
.PP
.B find
--
1.5.2.1
- [Findutils-patches] [PATCH] Add find -prune|cpio example to find manpage,
James Youngman <=