Wondering what use the yes command might be, I stumbled upon this comment, and tried to execute

yes $(yes yes)

From what I understand, this should simply print out an infinite sequence of yes, but instead it outputs nothing and crashes my graphical terminal after a few seconds. (If I execute it on tty1, I see the login prompt after some time.)

What is happening here?

  • 2
    I'm not an expert, but it might be that the first invocation is trying to print infinity infinite times. (or the argument may simply be too long.)
    – strugee
    Commented Nov 10, 2013 at 12:27
  • 5
    @strugee The argument list is never populated, because yes never returns.
    – Chris Down
    Commented Nov 10, 2013 at 14:58
  • @strugee You can get "infinity infinite times" using xargs: yes yes | xargs -P 0 yes (or without -P 0 for single-process infinity) Commented Jan 6, 2016 at 22:40

2 Answers 2


It should already be enough to run

 echo $(yes yes)

The $(...) runs the inner command until it is finished and captures all its output. - Now as yes runs a long time and generates a lot of output, bash will eventually run out of memory and crash.


To see the message for the error which closes your shell, you need to run a sub-shell.

$ sh
$ kill -9 $$

$ sh
$ yes $(yes yes)
sh: xrealloc: cannot allocate 18446744071562067968 bytes
  • 3
    16 million gigabytes, eh? Gordon Moore is lurking in a corner going, "Well... I mean, not quite yet..."
    – FeRD
    Commented Apr 15, 2019 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .