Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cp, exclude files; rm recursive

12 views
Skip to first unread message

Matthew Weaver

unread,
Sep 25, 2000, 3:00:00 AM9/25/00
to
1. Can I get cp to exclude certain files, either by name or by
globbing pattern?

Something like:
cp sourcedir/* destdir/ --exclude sourcedir/*.snm

2. Can rm search for and remove a file or pattern selectively, at more
than one directory level. I.e. if backup files are scattered at
several levels, and I want to remove them all:
rm *~ --recursive
The -R option only seems to work when removing everything.

Thanks.

-Matthew

Ken Pizzini

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
On Mon, 25 Sep 2000 18:11:17 -0700,
Matthew Weaver <msw_...@yahoo.com> wrote:
>1. Can I get cp to exclude certain files, either by name or by
>globbing pattern?
>
>Something like:
>cp sourcedir/* destdir/ --exclude sourcedir/*.snm

No, cp does not offer that option. But you can achieve the
same end with other tools; for example:
find sourcedir/* -type d -prune -o ! -name \*.snm -print0 |
cpio -pd --null destdir

>2. Can rm search for and remove a file or pattern selectively, at more
>than one directory level. I.e. if backup files are scattered at
>several levels, and I want to remove them all:
>rm *~ --recursive
>The -R option only seems to work when removing everything.

Again, not directly. But consider:
find . -name \*~ -print0 | xargs -0 rm

--Ken Pizzini

Matthew Weaver

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
Glad I asked; I wouldn't have figured those out myself. Thanks!
-Matthew
0 new messages