[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [debian-mentors] config.sub and config.guess | .diff.gz bloat

On Thu, Nov 06, 2003 at 07:43:46PM +0000, Magosányi Árpád wrote:
> +       find . -name config.{log,status,cache} |xargs rm -f

Two things:
Does -name config.{log,status,cache} actually work for you? It doesn't
do for me:
ametzler@downhill:/tmp/test> touch config.log
ametzler@downhill:/tmp/test> find . -name 'config.{log,status,cache}'
ametzler@downhill:/tmp/test> find . -name config.{log,status,cache}
find: paths must precede expression
Usage: find [path...] [expression]

Never ever use "|xargs rm -f".
ametzler@downhill:/tmp/test> mkdir -p 'evil /etc/passwd /'
ametzler@downhill:/tmp/test> touch 'evil /etc/passwd /config.sub'
ametzler@downhill:/tmp/test> find . -name config.sub | xargs rm -v
rm: cannot remove `./evil': No such file or directory
removing `/etc/passwd'
rm: cannot unlink `/etc/passwd': Permission denied
rm: cannot remove `/config.sub': No such file or directory

If you combine find with anything that modifies the results (mv, rm,
cp, ...) _always_ use either
find ... -exec rm '{}' \;
or [1]
find ... -print0 | xargs -0r rm -f

             cu andreas

[1] This is a lot faster, but won't work with every find. It is safe
to use on Debian though because we use GNU findutils.
"See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf,
fuhggvat qbja gur juveyvat tha.
Neal Stephenson in "Snow Crash"

Attachment: pgp0dEqKS1MDg.pgp
Description: PGP signature

Reply to: