Find and copy files
i faced an issue something like this...
Actually, in two ways you can process find
command output in copy
command
If
find
command's output doesn't contain any space i.e if file name doesn't contain space in it then you can use below mentioned command:Syntax:
find <Path> <Conditions> | xargs cp -t <copy file path>
Example:
find -mtime -1 -type f | xargs cp -t inner/
But most of the time our production data files might contain space in it. So most of time below mentioned command is safer:
Syntax:
find <path> <condition> -exec cp '{}' <copy path> \;
Example
find -mtime -1 -type f -exec cp '{}' inner/ \;
In the second example, last part i.e semi-colon is also considered as part of find
command, that should be escaped before press the enter button. Otherwise you will get an error something like this
find: missing argument to `-exec'
In your case, copy command syntax is wrong in order to copy find file into /home/shantanu/tosend
. The following command will work:
find /home/shantanu/processed/ -name '*2011*.xml' -exec cp {} /home/shantanu/tosend \;