I have a list of files generated using find that I want to feed (pipe) to cp. My problem is that the files have spaces and apostrophes in them, leading cp to repeatedly complain that it "cannot stat". Is there an elegant solution to this problem?
2 Answers
Another option is to skip -print0 and the pipe, and instead use the -exec cp {} path/to/dest/ + or -exec cp {} path/to/dest \; commands to find. The first replaces {} with a whole bunch of found filenames at once; the second copies found files one-at-a-time. These commands are present on most find implementations.
xargs--nullor-0argument.printfcommand or the-printfoption to find? Note thatfind ... -print0is equivalent tofind ... -printf '%p\0'finduntil I discoveredrsync...