I was trying to execute this command to fix yet another error (Unable to use a TTY - input is not a terminal or the right kind of file):

kubectl get pods -n foobar | grep baz | awk '{print $1}' | xargs -J % kubectl exec -it -n foobar % /bin/bash

Which resulted in the following error:

xargs: invalid option -- 'o'

I was able to execute the command correctly on my Mac Mojave, but not on Ubuntu 16.04.

According to the xargs website, there should have been a -o option:



Reopen stdin as /dev/tty in the child process before executing the command, thus allowing that command to be associated to the terminal while xargs reads from a different stream, e.g. from a pipe. This is useful if you want xargs to run an interactive application.

grep -lz PATTERN * | xargs -0o vi

But man xargs did not show this option.

The changelog did not mention any change to the flag.

My xargs version on Ubuntu 16.04 LTS:

xargs (GNU findutils) 4.7.0-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley.

1 Answer 1


The -o option which you want was added in 2017. Your version is from 2016. You need to upgrade.


Note the year in your version message:

Copyright (C) 2016 Free Software Foundation, Inc.

Now, look at this section from the findutils ChangeLog:

2017-06-08  Bernhard Voelker  <mail@bernhard-voelker.de>

        xargs: add -o, --open-tty option
        This option is available in the xargs implementation of FreeBSD, NetBSD,
        OpenBSD and in the Apple variant.  Add it for compatibility.


man xargs from the 2016 version shows this example for a work-around:

xargs sh -c 'emacs "$@" < /dev/tty' emacs

This example is for emacs but the same idea applies to any other command that you may wish to run. Like the -o option, this approach assures that the command that is being run has access to a terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.