I have a folder structure with a bunch of *.csv files scattered across the folders. Now I want to copy all *.csv files to another destination keeping the folder structure.
It works by doing:
cp --parents *.csv /target
cp --parents */*.csv" /target
cp --parents */*/*.csv /target
cp --parents */*/*/*.csv /target
...
and so on, but I would like to do it using one command.
'{}'
works just as well – OrangeDog Dec 07 '15 at 17:44find
manual I just found out it's recommended to use-execdir
instead of-exec
. The manual says:There are unavoidable security problems surrounding use of the -exec action; you should use the -execdir option instead.
– ArianJM Apr 15 '16 at 09:42-execdir
is safer than-exec
, simply replacing one with the other does not preserve the folder structure as intended. – sshine Aug 23 '16 at 11:33.
? – KernelPanic Jan 05 '17 at 13:59cp
is telling you that these subdirs are not being copied. You adapted the command to your needs, and whatever you have in-name
includes subdirs, which in the "csv" example, it didn't. You would need-r
to recursively copy the subdirs; but you don't want that, because copying the subdirs is being covered by thefind
itself. Depending on what you're doing, obviously. Maybe you want. But most probably not. :$ – msb Mar 05 '18 at 18:52;
is encountered. The string{}
is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find. Both of these constructions might need to be escaped (with a'\'
) or quoted to protect them from expansion by the shell." – Paul Rougieux Sep 14 '18 at 11:37