xargs (Re: Vypalovacka NEC NR7800)
Zdenek Pytela
letty na mrakoplas.phil.muni.cz
Úterý Listopad 27 14:13:33 CET 2001
David Jez píše:
> > echo -n "[ vytvarim MD5 checksum: "
> > #find cdrom | xargs md5sum -b 1> md5sum 2>/dev/null
> > echo -n > md5sum
> > find cdrom -exec md5sum -b "{}" >> md5sum \; 2>/dev/null
> > echo "done. ]"
> > echo
> Pro hnidopichy podotykam, ze xargs jsem zrusil kvuli souborum s mezerou
> v nazvu...
A jak už to my hnidopiši děláme:
xargs (1):
...
OPTIONS
--null, -0
Input filenames are terminated by a null character
instead of by whitespace, and the quotes and back-
slash are not special (every character is taken
literally). Disables the end of file string, which
is treated like any other argument. Useful when
arguments might contain white space, quote marks,
or backslashes. The GNU find -print0 option pro-
duces input suitable for this mode.
...
find (1):
...
-print0
True; print the full file name on the standard out-
put, followed by a null character. This allows
file names that contain newlines to be correctly
interpreted by programs that process the find out-
put.
...
U xargs je to hned první uvedený přepínač. Je to zkrátka tak, že
kombinace find -exec je skoro vždycky nejenom méně efektivní, ale někdy dá
špatné výsledky. xargs je fakt dobrá věc. Podobné přepínače mají skoro
všechny programy, právě kvůli souborům pojmenovaným po windowsovsku jako
věta plná mezer. Ještě jednou: find jedině s xargs.
find . -type f | xargs ...
--
--Zdeněk Pytela, <letty na mrakoplas.phil.muni.cz>
Další informace o konferenci Linux