Sherm Pendley wrote: > Peter Otten <__pete...@web.de> writes: > >> Carl Banks wrote: >> >>> Well the former deletes all the pyc files in the directory tree >>> whereas the latter only deletes the top level __pycache__, not the >>> __pycache__ for subpackages. To delete all the __pycache__s you'd >>> have to do something like this: >>> >>> file . -name __pycache__ -prune -exec rm -rf {} \; >>> >>> or, better, >>> >>> file . -name __pycache__ -prune | xargs rm -rf >>> >>> Still not anything really difficult. (I don't think a lot of people >>> know about -prune; it tells find don't recursively descend.) >> >> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? > > Exec launches a new instance of 'rm' for each found file, while xargs > launches a single instance, and passes the list of found files as arg- > uments. > > Probably not a big deal in this case, but if you're passing a long list > of files to a script that has a long startup time, it can make a big > difference.
You can avoid that: $ touch {1..10}.txt $ find . -exec python -c'import sys; print sys.argv' {} \; ['-c', '.'] ['-c', './10.txt'] ['-c', './1.txt'] ['-c', './7.txt'] ['-c', './8.txt'] ['-c', './4.txt'] ['-c', './6.txt'] ['-c', './3.txt'] ['-c', './5.txt'] ['-c', './9.txt'] ['-c', './2.txt'] $ find . -exec python -c'import sys; print sys.argv' {} \+ ['-c', '.', './10.txt', './1.txt', './7.txt', './8.txt', './4.txt', './6.txt', './3.txt', './5.txt', './9.txt', './2.txt'] Peter -- http://mail.python.org/mailman/listinfo/python-list