Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move or copy files listed by 'find' command in unix?

Tags:

find

unix

cp

mv

I have a list of certain files that I see using the command below, but how can I copy those files listed into another folder, say ~/test?

find . -mtime 1 -exec du -hc {} + 
like image 625
L P Avatar asked Jun 28 '13 15:06

L P


People also ask

How do I find and move a file in Linux?

Moving on the command line. The shell command intended for moving files on Linux, BSD, Illumos, Solaris, and MacOS is mv. A simple command with a predictable syntax, mv <source> <destination> moves a source file to the specified destination, each defined by either an absolute or relative file path.

How do you copy and move a file in Unix?

You can use the shell commands cp or pax or the TSO/E command OCOPY to copy files within the z/OS UNIX file system. Using the shell: Use the cp shell command to copy: One file to another file in the working directory, or to a new file in another directory.


1 Answers

Adding to Eric Jablow's answer, here is a possible solution (it worked for me - linux mint 14 /nadia)

find /path/to/search/ -type f -name "glob-to-find-files" | xargs cp -t /target/path/ 

You can refer to "How can I use xargs to copy files that have spaces and quotes in their names?" as well.

like image 145
Ankur Avatar answered Sep 21 '22 18:09

Ankur