cp: missing destination file operand?

Trying to execute the following command and getting error?

$ cp `find /app/instances/obb_inst/mdm3_obb/data/interface/outbound_mdm3_obb -maxdepth 0 -type f -name "*.dat" -cmin +120` /app/instances/obb_inst/mdm3_obb/data/interface/outbound_mdm3_obb/bak
cp: missing destination file operand after `/app/instances/obb_inst/mdm3_obb/data/interface/outbound_mdm3_obb/bak'
Who is Participating?
Dushyant SharmaCommented:
It is likely to throw this error if there is no file selected using the command. May be you should try the find part first and check if it is returning any matching value. If it is not then it will throw the error. Also you can try increasing maxdepth value to 1 or more to find the entries if they are not found using value 0.
Better off using xargs
find /app/instances/obb_inst/mdm3_obb/data/interface/outbound_mdm3_obb -maxdepth 0 -type f -name "*.dat" -cmin +120 | xargs -i cp {}  /app/instances/obb_inst/mdm3_obb/data/interface/outbound_mdm3_obb/bak

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.