Mon 09 May 2005 11:59:32 PM UTC, original submission:
I can't xargs to work as I would expect it when I give it both the -i and -l args. Using -i specifies -l1 (as the documentation indicates) and using -l seems to disable the functionality provided by -i.
This can be evidenced by using the following program:
main ( int argc, char **argv ) { int i; for (i = 0; i < argc; i ++) { printf("Arg %d: [%s]\n", i, argv[i]); } }
When I build it and run it from xargs, I get the following:
> echo -e 'a\nb\nc' | xargs -l10 -i ./test {}
Arg 0: [./test]
Arg 1: [a]
Arg 0: [./test]
Arg 1: [b]
Arg 0: [./test]
Arg 1: [c]
> echo -e 'a\nb\nc' | xargs -i -l10 ./test {}
Arg 0: [./test]
Arg 1: [{}]
Arg 2: [a]
Arg 3: [b]
Arg 4: [c]
>
I was expecting to be able to combine -i and -l to get:
Arg 0: [./test]
Arg 1: [a]
Arg 2: [b]
Arg 3: [c]
I don't see anything in the semantics of -i and -l that makes them exclude each other. Of course, in -i, the replace string ({}) would get replaced with as many tokens from the input as permitted.
|