TricksAndTips.net
"Yes" command on Mac OS (and Linux) - what it is good for?

Mac OS

"Yes" command on Mac OS (and Linux) - what it is good for?

By Admin,

There is a somewhat lesser known command named `yes` in both Linux and Mac OS which is useful for automating things in terminal.

It is mostly used as part of the command chaining for example:

yes | rm -r folder_name

and works so that the command specified after | (pipe) gives the answer “y” (yes) as if you entered it manually from the keyboard. In addition, it will provide it repeatedly, not only once - which you will see when you run it as a standalone command.

On Mac OS (and Linux), you can use yes alone to test how your computer / laptop behaves under load - if you run yes alone, the CPU will be 100% busy - a process called yes will take care of that. Than you have to kill the process (control + C in the terminal window or in the Activity Monitor).

For effective testing, it is advisable to open multiple terminal windows and run yes in each of them

If you do not want to see the flood of "y" characters, use:

yes > /dev/null &

To quit all running yes proccesses on Mac Os (or Linux) use:

killall yes