I don't think the `xargs -n 4` in the middle is robust. For example,
when the input contains spaces, it won't work as expected. Is there a
way to make it robust?

$ printf '%s\n' {a..d} | xargs -n 4
a b c d
$ printf '%s\n' 'a  b' 'c  d' 'e  f' 'g  h' | xargs -n 4
a b c d
e f g h

On 3/8/20, James Youngman <j...@gnu.org> wrote:
> You should be able to do this by chaining use of xargs :-
>
> $ seq 1 208  | xargs -n 4 | xargs -d'\n' -n 5 sh -c 'set $@;
> my-command $@' ignored
>
> The use of -n in the second xargs invocation is not needed, it's just
> there to show more clearly what is happening.
>


-- 
Regards,
Peng

Reply via email to