Terminal – How to Specify Target Directory with mv

command linefilehomebrewterminal

I'm trying to move some files with GNU find on the command line, as in this answer:

gfind path_A -name '*AAA*' -exec mv -t path_B {} +

(added a 'g' prefix to find to use the Homebrew version of find.)

Problem: MacOS' version of mv doesn't have the -t switch and without it the command doesn't work. So, how can I move files with find on MacOS?

Best Answer

As you are using the GNU version of find you might as well use a GNU version of mv which will understand the -t argument.

Under Macports and Homebrew mv is part of the coreutils package and installing that will put gmv on your path.

Macports installation is by

sudo port install coreutils