Reputation: 309
I am trying to move a folder and his content to a different location on the server. Folder can be anywhere but I have to move it to a specific location. So far I have tried something like this, but its not working
find / -name 'test_folder' -exec mv 'test_folder' /Users/michael/Downloads/here/. {} +
Any suggestions, what am I doing wrong?
Also what would be variation of this command in .sh
?
Upvotes: 0
Views: 138
Reputation: 531708
You have to give mv
the full name of the folder found, not just the immediate name: /some/other/dir/test_folder
, not test_folder
. Use
find / -name test_folder -exec mv '{}' /Users/michael/Downloads/here +
UPDATE: The +
form of -exec
seems to require that {}
be the final argument of the command, unlike with the ;
version.
# Less efficient, as `mv` is called for every found directory
find / -name test_folder -exec mv '{}' /Users/michael/Downloads/here \;
or
# More complicated, but less overhead
find / -name test_folder -exec sh -c 'mv "$@" /Users/michael/Downloads/here' {} +
Upvotes: 2