Xargs can be used to cut up the contents of standard input into manageable pieces and invoke a command on each such piece. But is it possible to know which piece it is ? To give an example:
seq 1 10 | xargs -P 2 -n 2 mycommand
will call
mycommand 1 2 &
mycommand 3 4 &
mycommand 5 6 &
mycommand 7 8 &
mycommand 9 10 &
But I would like to know in my "mycommand" script that
mycommand 1 2
is processing the first piece/segment, and so on. Is it possible to access that information ?
p.s. In the simple example above I can just look at the numbers and tell. But for arbitrary lists how does one access the information without actually injecting piece# in the input stream ?