Skip to main content
fixed typo
Source Link
phk
  • 6.1k
  • 7
  • 44
  • 76

You should also take into account that -exec nicely handles filenames/paths with spaces, but when you pipe in the output from find to another program that can cause problems. Therefore some programs that expect a list of filenames from stdin can be given an option to have those filenames NUL seperatedseparated (often -0 or --null). And find has and option to give them to the next program in that way by specifying: -print0

You should also take into account that -exec nicely handles filenames/paths with spaces, but when you pipe in the output from find to another program that can cause problems. Therefore some programs that expect a list of filenames from stdin can be given an option to have those filenames NUL seperated (often -0 or --null). And find has and option to give them to the next program in that way by specifying: -print0

You should also take into account that -exec nicely handles filenames/paths with spaces, but when you pipe in the output from find to another program that can cause problems. Therefore some programs that expect a list of filenames from stdin can be given an option to have those filenames NUL separated (often -0 or --null). And find has and option to give them to the next program in that way by specifying: -print0

added 6 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
find . -type f -iname "*.cr2" -exec cp {}-t destination_directory {} +

Out(As G-Man pointed out the {} has to be at the end, before the +) All of the above do not build the hierarchy under the target directory for that and out of long habit even if the source directory is flat, I find myself using cpio instead:

find . -type f -iname "*.cr2" -exec cp {} destination_directory +

Out of long habit I find myself using cpio instead:

find . -type f -iname "*.cr2" -exec cp -t destination_directory {} +

(As G-Man pointed out the {} has to be at the end, before the +) All of the above do not build the hierarchy under the target directory for that and out of long habit even if the source directory is flat, I find myself using cpio instead:

added 6 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
find . -type f -iname "*.cr2" -exec cp {} destination_directory +
find . -type f -iname "*.cr2" cp {} destination_directory +
find . -type f -iname "*.cr2" -exec cp {} destination_directory +
added 18 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
Loading
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228
Loading