I ran into a problem something like this ...
In fact, in two ways you can handle the output of the find in the copy command
If the output of the find does not contain a space. If the file name does not contain a space, you can use the command below:
Syntax: find <Path> <Conditions> | xargs cp -t <copy file path> find <Path> <Conditions> | xargs cp -t <copy file path>
Example: find -mtime -1 -type f | xargs cp -t inner/ find -mtime -1 -type f | xargs cp -t inner/
But most of the time, our production data files may contain spaces in it. Therefore, most of the time below the specified command is safer:
Syntax: find <path> <condition> -exec cp '{}' <copy path> \;
Example find -mtime -1 -type f -exec cp '{}' inner/ \;
In the second example, the last part of the ie half-colony is also considered as part of the find , which must be escaped before pressing the enter button. Otherwise, you will receive an error message
find: missing argument to `-exec'
In your case, the copy command syntax is incorrect to copy the search file to /home/shantanu/tosend . The following command will work:
find /home/shantanu/processed/ -name '*2011*.xml' -exec cp {} /home/shantanu/tosend \;
Thiyagu ATR Dec 07 '13 at 18:18 2013-12-07 18:18
source share