Unix Command - yes
The basic usage:
yes
This will flood your terminal with y
, to stop it press Ctrl + C
.
To customize the output, provide a string:
yes "Hello, world!"
This will continuously print "Hello, world!"
on new lines.
Practical Uses of yes
Automatically Confirm Prompts
yes | sudo apt-get remove package-name
This will keep the CPU busy by continuously sending output to /dev/null
.
Creating Large Files Quickly
Need a large file for testing? Use yes
with head
:
yes "data" | head -n 100000 > file.txt
This creates a file with a million lines of "data"
.