Operating System - Linux
1748180 Members
3942 Online
108759 Solutions
New Discussion юеВ

Re: help me copy via "find"

 
SOLVED
Go to solution
Maaz
Valued Contributor

help me copy via "find"

I want to copy all the rpm under /rep directory to /test directory

# ls /rep
i586 noarch x86_64

# ls /rep/i586/
a.rpm b.rpm c.rpm


# find /rep -name "*rpm" -exec cp -rv - /test {}\;

find: missing argument to `-exec'


4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: help me copy via "find"

> ... -exec cp -rv - /test {}\;

You need a space before the backslash. Also I would think you would need the {} first?
Uwe Zessin
Honored Contributor
Solution

Re: help me copy via "find"

# find /rep -name "*rpm" -exec cp -rv {} /test/ \;

But all files will end in /test - no subdirectories are being created.
.
Frank_W
Frequent Advisor

Re: help me copy via "find"


Hi,

you can also use:

cd /rep
find . -name "*rpm" -print | cpio -pdvm /test/
Maaz
Valued Contributor

Re: help me copy via "find"

excellent help
Dear Dennis Handly, yes I have to write "{}" before the destination (/test), as Uwe Zessin posted.

Nice help Dear Uwe Zessin, and Frank_W for the superb help ;)