« Back to Index

macOS: find files asynchronously

View original Gist on GitHub

Tags: #xargs #async #find

async.sh

#!/bin/bash

replacement_patterns() {
  echo "Processing file: $1"
}

replacement_patterns "$@"

main.sh

# on macOS we have to use a separate shell process with a separate script file for async processing to work...

find "/Users/integralist/Code/path/to/directory" -type f -print0 | xargs -0 -P "$(nproc)" -n 1 bash -c './async.sh "$@"' _