man xargs pour comprendre:
(extrait d'une page man sous aix):
1. To use a command on files whose names are listed in a file, enter:
xargs lint -a <cfiles
If the cfiles file contains the following text:
main.c readit.c
gettoken.c
putobj.c
the xargs command constructs and runs the following command:
lint -a main.c readit.c gettoken.c putobj.c
(...)
5. To construct a command that contains a specific number of arguments and to
insert those arguments into the middle of a command line, enter:
ls | xargs -n6 | xargs -I{} echo {} - some files in the directory
If the current directory contains files chap1 through chap10, the output
constructed will be the following:
chap1 chap2 chap3 chap4 chap5 chap6 - some files in the directory
chap7 chap8 chap9 chap10 - some file in the directory
Détails sur l'option -n:
-n Number Runs the Command parameter using as many standard input arguments as
possible, up to the maximum specified by the Number parameter. The xargs command
uses fewer arguments if:
1. If the accumulated command line length exceeds the bytes specified by the
-s Size flag.
2. The last iteration has fewer than Number, but not zero, arguments
remaining.
Note: The -L, -I (Lowercase L), and -n flags are mutually exclusive;
the last flag specified takes effect.
# cat inutile
Posté par totof2000 . En réponse au message Xargs et passage d'arguments.. Évalué à 5.
man xargs pour comprendre:
(extrait d'une page man sous aix):
1. To use a command on files whose names are listed in a file, enter:
xargs lint -a <cfiles
If the cfiles file contains the following text:
main.c readit.c
gettoken.c
putobj.c
the xargs command constructs and runs the following command:
lint -a main.c readit.c gettoken.c putobj.c
(...)
5. To construct a command that contains a specific number of arguments and to
insert those arguments into the middle of a command line, enter:
ls | xargs -n6 | xargs -I{} echo {} - some files in the directory
If the current directory contains files chap1 through chap10, the output
constructed will be the following:
chap1 chap2 chap3 chap4 chap5 chap6 - some files in the directory
chap7 chap8 chap9 chap10 - some file in the directory
Détails sur l'option -n:
-n Number Runs the Command parameter using as many standard input arguments as
possible, up to the maximum specified by the Number parameter. The xargs command
uses fewer arguments if:
1. If the accumulated command line length exceeds the bytes specified by the
-s Size flag.
2. The last iteration has fewer than Number, but not zero, arguments
remaining.
Note: The -L, -I (Lowercase L), and -n flags are mutually exclusive;
the last flag specified takes effect.