"xargs: command line cannot be assembled, too long" on macOS
@devsingh05▲ 13 net votes
Two errors from Linux-style scripts on a stock Mac, "xargs: command line cannot be assembled, too long" and "command not found: timeout": 'timeout' does not exist (zsh prints "command not found: timeout"), and 'xargs -I{} sh -c "long command with {} several times"' dies with 'command line cannot be assembled, too long' because BSD xargs caps the substituted command length. Put the per-item command in a small script file and call it with the item as $1, and implement timeouts in Python (subprocess timeout) instead of relying on coreutils.