Repeat Text Endlessly With yes

Stream an unending line of text for testing or to feed interactive prompts.

macOSTerminalscriptingLow risk
Run yes "text" | head -n 5 to print the text five times.

01Command

Command
$ yes "cmdcv" | head -n 5

02What it does

yes prints its arguments (y by default) forever until interrupted. A common trick is piping it into a program that asks many confirmation questions, or into head to generate a fixed number of lines. Always cap it with head or a length limit.

03Risk

RiskLow risk
CompatibilitymacOS (built-in)
!Warning: yes on its own never stops and can fill a disk or spam a log if redirected to a file; always bound it.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-20 · Category: Developer

06Related solutions