Skip to main content
4 of 4
added 380 characters in body
amphetamachine
  • 5.6k
  • 2
  • 38
  • 43

To expand on the answers already provided, xargs can do one cool thing that is becoming increasingly important in today's multicore and distributed computing landscape: it can parallel process jobs.

For example:

find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8

will encode *.wav => *.flac, using three processes at once (-P 3).

Update 2024:

GNU Parallel, initially released 2020-05-22, is another tool that may be better suited to parallelizing processes. Here's the same command as above using parallel instead:

find . -type f -name '*.wav' -exec parallel --jobs=3 flac -V8 ::: {} +

Omit --jobs=3 to auto-utilize all CPU threads at once.

amphetamachine
  • 5.6k
  • 2
  • 38
  • 43