Re: specify a multiple of m arguments in xargs

2020-03-08 Thread Andreas Metzler
On 2020-03-08 Peng Yu wrote: > 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? NUL as delimiter? cu Andreas

Re: specify a multiple of m arguments in xargs

2020-03-08 Thread Peng Yu
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 Y

Re: specify a multiple of m arguments in xargs

2020-03-08 Thread James Youngman
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.

Re: specify a multiple of m arguments in xargs

2020-03-06 Thread Peng Yu
Instead of manually specify -n that is a multiple of m which could overflow, maybe xargs should have an additional argument to allow -n be the maximum allowable multiple of m? > $ seq 100 | xargs -n $(( 5 * 2000 )) printf '%s\t%s\t%s\t%s\t%s\n' > /tmp/1.txt > $ < /tmp/1.txt awk -e '!($1 &&

Re: specify a multiple of m arguments in xargs

2020-03-06 Thread Peng Yu
No. I have a program that expects m*n arguments instead of just m (n is an interger). Using `xargs -n m` would make calling the program too many times. On 2/21/20, Bernhard Voelker wrote: > On 2020-02-20 20:46, Peng Yu wrote: >> Hi, >> >> xargs by default does not put a multiple of m arguments (m

Re: specify a multiple of m arguments in xargs

2020-02-21 Thread Bernhard Voelker
On 2020-02-20 20:46, Peng Yu wrote: > Hi, > > xargs by default does not put a multiple of m arguments (m is an > integer greater than 1) to the command line. But is there a way that I > can make sure only a multiple of m arguments are put the command line. For my understanding: you have a program