Re: Recursive copies of selected files
On Thu, Sep 16, 2004 at 03:37:42PM -0700, Bill Moseley wrote:
> This is going to be a "doh!" question, I'm sure.
>
> I needed to copy a bunch of files from a directory tree -- but only
> selected files (say all regular files that end in .foo). I want the
> destination tree to be created. find(1) is what I find most useful
> for specifying what files to match the files I want to move -- but I
> can't seem to get a good xargs command to get the files in the
> destination (ie create the dir if doesn't exist and copy the file).
>
> rsync would also be good, but I can't get the --exclude and --include
> options to work, either.
>
> I used brute force and used find to generate the list of files, then
> tar with --files-from option and then untarred in the destination.
>
> Now I'm feeling dumb. There must be a one-liner to do this.
It seems the "standard" way to do this is tar in a pipe.
find . | tar -F. -c -f- | (cd ../new && tar -xf -)
--
The world's most effective spam filter:
ln -sf /dev/full /var/mail/$USER
Reply to: