From the mv
man page
-t, --target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY
mv
's default behavior is to move everything into the last argument so when xargs
executes the command it does it like
mv /destinationFolder pipedArgs
without the -t
it would try to move everything into the last arg piped to xargs. With the -t
you're explicitly saying to move it HERE.
From the xargs
man page
-n max-args
Use at most max-args arguments per command line. Fewer than max-args arguments will be used if the size (see the -s option) is exceeded, unless the -x option is given, in which case xargs will exit.
Normally xargs
will pass all the args at once to the command. For example
echo 1 2 3 4 |xargs echo
1 2 3 4
executes
echo 1 2 3 4
While
echo 1 2 3 4 |xargs -n 1 echo
executes
echo 1
echo 2
echo 3
echo 4
find
with a suitable time predicate (-mtime
,-newerXY
etc.) for this task, rather than parsing the output ofls -lr
– steeldriver Jul 06 '16 at 20:08-t
option formv
is not in the POSIX standard, and not all versions ofmv
have it — for example, macOS doesn't. – gidds Jun 05 '22 at 10:57