xargs on OSX: illegal option --

xargs on Mac OS X doesn't support the --replace option; you can use -I instead:

find docs/ -name "*png" | xargs -I F python myscript.py "F"

The strange error message is produced because this version of xargs interprets characters after a single - as options, so with --replace it's looking for an option named -, which doesn't exist.


Mac OSX xargs does not support long options like GNU xargs. For using --replace like GNU xargs, use -I:

find docs/ -name "*png" | xargs -I F python myscript.py "F"

Note that this approach breaks with file name contain newline, you want to use find -print0 with xargs -0:

find docs/ -name "*png" -print0 | xargs -0 -I F python myscript.py "F"

or standard one:

find docs/ -name "*png" -exec python myscript.py {} +

Tags:

Xargs

Osx