Tuesday, July 20, 2010

Just say yes

Linux has a "yes" command. I found it today when I was messing with Cygwin, actually. It's an odd little command at first: you feed it a string like this:

yes hello

and it repeats that string until you kill it:

hello
hello
hello
...

If you don't give it a string, it outputs a series of 'y' characters....

y
y
y
...

...which provides the hint to its real use: it's for automatically answering the prompts on an interactive script. Go here for some examples.

Cygwin itself is worth mentioning. I don't actually venture out onto the Linux command line itself much, because I'm usually working on a Windows box. Cygwin provides a Linux-like environment on a Windows box.

1 comment:

  1. Thanks for the tip! I just checked and 'yes' is on my Mac too. I loved Cygwin when I used Windows.

    ReplyDelete