Winker
Winker

Reputation: 925

Is "xargs" on MacOS not the same as linux?

For the following command:

docker ps -a -q | xargs -r docker kill

I get this error:

xargs: illegal option -- r

What would be the MacOS equivalent of the above command?

Upvotes: 9

Views: 11758

Answers (1)

user149341
user149341

Reputation:

The equivalent is simply docker ps -a -q | xargs docker kill.

-r (aka. --no-run-if-empty) is only necessary on GNU xargs because it will always run the command at least once by default, even if there is no input; -r disables this. BSD xargs does not have this behavior, so there's no need to disable it.

Upvotes: 12

Related Questions