Be Repetitively Affirmative

If someone were to come up to me in the street and ask me what makes Unix so damn cool, I’d point them to the yes command. Here’s its man page (OS X version):

YES(1)

NAME
    yes -- be repetitively affirmative

SYNOPSIS
    yes [expletive]

DESCRIPTION
    yes outputs expletive, or, by default, 'y', forever.

That’s right: the only purpose of this thing is to spit out the letter y, over and over again. Try it. Find a Unix prompt somewhere and type yes. You’ll get this:

y  
y  
y  
y  
y  
y  
...

… ad infinitum, until you stop the process. If you type yes no, you’ll get this:

no  
no  
no
no  
no
...  

There’s something beautifully zen about the pointlessness of yes1, and something sublimely perverse in the documentation’s insistence that the optional argument be an expletive — not a word, or a phrase, or a thing-that-must-be-repeated-for-no-apparent-reason. No. Specifically, an expletive. The only thing that would make this command more awesome is if it actually enforced this restriction:

$ yes flowers  
yes: Invalid expletive

$ yes rainbows  
yes: Invalid expletive 

$ yes puppies  
yes: Stop wasting my time, asshole

$ yes poopy  
yes: Insufficient expletive

$ yes cacapoopydoodoo  
yes: Infantile expletive

$ yes crap  
yes: Closer, but no

$ yes fuck
yes: Yawn. How pedestrian.

$ yes George W Bush
George W Bush
George W Bush
George W Bush
George W Bush
George W Bush
George W Bush
...

If I were a computer science teacher, my first programming assignment would be to implement yes in Java, just to impress on my students how arbitrary and pointless life can be when left to its own devices. If I’m feeling particularly nasty, I wouldn’t let them use loops or recursion.

I feel an evil laugh coming on.


  1. Well, there is some point to it, I suppose. You can use it to stress your processor for performance tests. Also, as Matt points out in comments, you can use it to feed input to certain utilities that don’t implement ‘yes/no to all’ options. Still. 

1 comment so far ↓

#1 Matt Stocum on 12.02.07 at 10:27 am

I’ve actually had to use yes a few times. It essentially allows you to implement “Yes to all” or “No to all” or “George W Bush to all” for command line programs that aren’t kind enough to provide you with command line options that do the same.

There really is a zen-like coolness about yes though.

Leave a Comment