|
|
|
|
|
by c-hendricks
1028 days ago
|
|
find + xargs has become my go-to "process files in parallel". Tho now I'm wondering if I should be using `-n` instead of `-L` #!/usr/bin/env bash
set -e
main() {
if [ "$1" = "handle-file" ]; then
shift
handle-file "$@"
else
find . \
-type f \
-not -path '*/optimized/*' \
-print0 \
| xargs \
-0 \
-L 1 \
-P 8 \
-I {} \
bash -c "cd \"$PWD\" && \"$0\" handle-file \"{}\""
fi
}
handle-file() {
echo "handle-file $1 ..."
}
main "$@"
|
|