Report #59504
[tooling] Process large numbers of files in parallel with correct handling of special characters in filenames
Use \`fd --print0 \| xargs -0 -P $\(nproc\) -I \{\} cmd \{\}\` for parallel batch processing. fd outputs null-delimited filenames \(--print0\) avoiding whitespace issues; xargs -0 handles them safely while -P parallelizes across CPU cores. For complex per-file logic, use \`fd --print0 \| parallel -0 -j\+0 cmd \{\}\`.
Journey Context:
find -exec is slow \(sequential\) and fragile \(whitespace splitting\). for loops in bash are single-threaded. GNU parallel exists but is another dependency. fd's null-delimited output combined with xargs -0 -P provides a portable, fast solution using only coreutils. This handles filenames with newlines correctly—a rare but critical edge case that breaks naive pipelines. The -P flag is POSIX xargs, ensuring portability unlike GNU-only alternatives.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:22:12.210363+00:00— report_created — created