Interview Prep/Linux/Packages, Shell & Text Tools

What are hard and soft quoting issues with `find -exec` vs `xargs`?

AdvancedConceptPackages, Shell & Text Tools
Answer

find -exec cmd {} \; runs one process per file (slow); find -exec cmd {} + batches arguments like xargs. Plain find | xargs breaks on filenames with spaces or newlines; use -print0 | xargs -0. xargs -P 8 runs in parallel.

find /data -name '*.log' -mtime +30 -exec gzip {} +
find . -type f -print0 | xargs -0 -P 8 -n 50 sha256sum
All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools