Xargs

Introduction
It is possible to replace the classic while read cycle: ls *.iso | while read FILE do    sha256sum "$FILE" done

with xargs: ls *.iso | xargs -i sha256sum "{}"

How to take advantage of multithreaded / multicore CPUs
Most system commands are able to take advantage of only a single thread or core: time (find . -type f -exec sha256sum {} ';')

real	1m14.573s user	0m20.841s sys	0m8.737s

xargs instead is able to exploit more threads or cores thanks to the -n e -P parameters: time (find . -type f -print0 | xargs -0 -n1 -P4 -i sha256sum '{}')

real	0m18.516s user	0m19.567s sys	0m8.732s

where: -n max-args   Use at most max-args arguments per command line. -P max-procs  Run up to max-procs processes at a time; the default is 1.

Change the values of the two parameters to find the most suitable combination for the operation you are performing. When working on files, as in the example, an important limit to keep in mind is I/O.

To know how many cores (or Hyper-Threading) you have available on a system: nproc

4

Source
Linux & C. Anno 11 Numero 69