yes - macOS
Overview
yes infinitely outputs a single word or phrase to stdout, primarily used for confirming prompts or supplying continuous input. It effectively automates repetitive yes responses in scripts or command chains.
Syntax
yes [STRING]
Options/Flags
None
Examples
- Infinitely output “Yes”:
 
yes
- Output “Hello” 20 times:
 
yes "Hello" | head -n 20
- Automatically confirm a script’s prompt:
 
script.sh | yes
Common Issues
- Accidental Execution: Ensure you intend to execute yes as it can potentially cause unintended consequences by automatically confirming prompts.
 
Integration
- Bash Scripting: Use yes to automate user input within bash scripts, ensuring a consistent flow without requiring manual confirmation.
 - Continuous Input: Combine yes with other commands to provide an endless stream of input, such as testing programs that expect user responses.
 
Related Commands
- echo: Echoes a string to stdout
 - head: Outputs the first n lines of input
 - tail: Outputs the last n lines of input
 - more: Interactively displays output, allowing page-by-page navigation