Skip to content

.tip

· one of the small things

xargs -P is the parallel loop you already have

Processing a thousand files one at a time on an eight core machine wastes seven of the cores. xargs -P runs the command in parallel, and -n sets the batch size.

find . -name '*.png' -print0 | xargs -0 -P 8 -n 10 optimise

Use -print0 and -0, so a file name with a space in it doesn't turn into two arguments.

shell