Im trying to find a set number of files in a directory and then copy them to another directory using the find and cp command.

this is the command i have so far:

find /usr/share -name a* -type f -group admin -size -10240c | cp /usr/share/ ./thecopy/

Now it finds the files but does not copy the files to the location I'm trying to send them but finds the files in question. Any suggestions please?

没有正确的解决方案

其他提示

find /usr/share -name a* -type f -group admin -size -10240c -exec cp {} ./thecopy/\;

That won't recreate any directory structure under thecopy. But will copy the files it finds to your directory needed

Try something like:

find /usr/share -name a* -type f -group admin -size -10240c | cp {} ./thecopy/ \;

{} is the placeholder for the files that match your criteria

If you want to retain the directory structure you can try something like:

find /usr/share -name a* -type f -group admin -size -10240c | rsync -av {} ./thecopy/ \;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top