TIL: auto-input yes/no/anything to command prompts

Have you ever been running a script or command, and just want to easily pass “yes” to all prompts? It turns out there’s a simple command for that: yes.

Piping yes to a script will provide every script prompt with a y response. In fact, yes can take a single argument, allowing us to customize the text we want returned (eg. yes n will return n to every script prompt). According to the man page, yes was written with a specific use-case in mind:

Screen Shot 2018-08-15 at 1.29.40 PM

My own use-case is much less aggressive: pruning stopped containers.

Screen Shot 2018-08-15 at 1.39.27 PM.png

Published by

Kirk Wight

I am a Code Wrangler at Automattic, helping make WordPress.com the best it can be. Pender Island, British Columbia, Canada is where I call home. Lover, not a fighter.

One thought on “TIL: auto-input yes/no/anything to command prompts”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s