I read in this answer from @Gilles the following:
In zsh, you can load the
mv
builtin:setopt extended_glob zmodload -Fm zsh/files b:zf_\* mv -- ^*.(jpg|png|bmp) targetdir/
as a solution to the "mv: Argument list too long”
problem. The answer suggests using zsh's mv
(as opposed to GNU's) but what exactly does this line do?:
zmodload -Fm zsh/files b:zf_\*
Best Answer
The best way, to look at zsh documentation is using
info
.If you run
info zsh
, you can use the index (think of a book's index) to locate the section that describes thezmodload
command.Press i, then you can enter
zmo
and press Tab. You'll get straight to thezmodload
builtin description which will tell you all about it.In short,
zmodload -F
loads the module (if not loaded) and enables only the specified features from that module.With
-m
, we enabled the features that match a pattern, hereb:zf_*
.b:
is for builtin, so the above command loads thezsh/files
module (seeinfo -f zsh -n 'The zsh/files Module,'
for details on that) and only enables the builtins whose name starts withzf_
.loads the module, but doesn't enable any feature:
lists the features of that module specifying which are currently enabled (none for now). You'll notice there's both a
mv
andzf_mv
builtin.You'll notice the
zf_mv
builtin has been enabled, but not themv
one (same for the other builtins). That means, those builtin versions of the system commands have been enabled, but without overriding the system one:Now that you have a builtin
mv
, aszf_mv
, notmv
, you can do:Because
zf_mv
is builtin, there's noexecve()
system call, so you won't hit theToo many args
limit associated with it.Of course, you can also do:
But beware that replaces the system's
mv
withzsh
builtin equivalent.To overcome the
E2BIG
execve()
error (the Too many args upon executing an external command),zsh
also provides with azargs
function.You run:
To mark it for autoloading.
Then you can use:
(here assuming GNU
mv
for the-t
option).zargs
will run as manymv
commands as necessary to avoid the E2BIG (asxargs
would do).