[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: specify a multiple of m arguments in xargs
From: |
Peng Yu |
Subject: |
Re: specify a multiple of m arguments in xargs |
Date: |
Sun, 8 Mar 2020 08:51:51 -0500 |
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 <address@hidden> 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