Subject: Re: upgrade to mv
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 08/15/2001 16:10:10
> it would mean i could do things like:
> 	find . -name \*.html -print0 | xargs -0 mv -d otherplace

The right place to fix this is xargs, not every program you find
yourself wanting to use with xargs.  I long ago wrote my own xargs
(largely to get rid of the quoting misfeatures in the stock one) and
gave it a way to do such things:

 *      -k<str> indicates that instead of taking the given command and
 *                arguments and appending the arguments derived from
 *                the input, xargs should modify and replicate certain
 *                arguments.  Any argument containing <str> will be
 *                replicated, once per string, as in
 *                      .... | xargs -kX mv dir1/X dir2
 *                which will run commands like
 *                      mv dir1/foo dir1/bar dir1/blee dir2
 *                If -k is not used, the effect is as if it were used
 *                with a string that does not otherwise occur, with one
 *                extra trailing argument, equal to that string, on the
 *                command.
 *      -r<c><s1><c><s2>
 *              indicates that certain argument(s) (or portions
 *                thereof) to the command are to be replicated.  If
 *                <s1> appears as an argument to the command, all
 *                arguments between that and the next argument equal to
 *                <s2> (or the last argument, if no argument equals
 *                <s2>) are replicated, appearing once per string.
 *                (Normally, -k will be used as well, and at least one
 *                of the replicated arguments will include the -k
 *                string, but this does not have to be so.)  If an
 *                argument to the command contains but is not equal to
 *                <s1>, then part of that argument is replicated.
 *                Specifically, everything from immediately after the
 *                <s1>, up to but not including the next <s2> (or the
 *                end of the argument if there is no following <s2>),
 *                is replicated.  If -k is used and the replicated
 *                portion contains the -k string, each copy will have
 *                the -k string replaced as appropriate.  For example,
 *                      xargs -kXX -r/A/B cmd mAjB blivet A -q XX -f mXX B -t
 *                will run commands like
 *                      cmd mjjj blivet -q foo -f mfoo -q bar -f mbar -q blee -f mblee -t
 *                while
 *                      xargs -kXX -r/A/B cmd -t mAjXXkB
 *                will run commands like
 *                      cmd -t mjfookjbarkjbleek
 *                Neither <s1> nor <s2> may be zero-length; it is also
 *                an error for the second <c> to be missing.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B