Use xargs to mv a directory from find results into another directory

With BSD xargs (for OS X and FreeBSD), you can use -J which was built for this:

find . -name some_pattern -print0 | xargs -0 -J % mv % target_location

That would move anything matching some_pattern in . to target_location

With GNU xargs (for Linux and Cygwin), use -I instead:

find . -name some_pattern -print0 | xargs -0 -I % mv % target_location

The deprecated -i option of GNU xargs implies -I{} and can be used as follows:

find . -name some_pattern -print0 | xargs -0 -i mv {} target_location

Note that BSD xargs also has a -I option, but that does something else.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)